Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added a "prototype" feature to Massive #28

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

Rob,

First, Massive is pretty damn cool. It's tiny, it's fast, and it is about as bare metal as you'd want when writing simple queries. However, I found I wanted to be able to do things like:

contact.Addresses()

Where "contact" is a DynamicModel and Addresses is a method added using the "prototype" feature described below. This feature makes it easy to add extension methods to crank out these simple cases, for example let's say I had an extension method called OneToMany, using it would look like:

var contact = new DynamicModel(connectionString, "Contact");
var address = new DynamicModel(connectionString, "Address");

contact.OneToMany(address);

The OneToMany extension method would simply add a callback to the Prototype collection on the DynamicModel object. The callback would then execute whatever query was necessary to fetch all Address records related to the given Contact record.

I actually implemented a sample project in a branch called "samples". Check it out if you want to know more. My whole point here was that I didn't want to make Massive larger, but I did want these kinds of features. Now I think I can add them external to Massive itself.

In general, this feature allows external tools to be developed to provide things
like automatic relationship fetching without actually extending the core Massive
code base. Another use would be for adding helper methods, validation routines, having
methods that correspond to specific stored procedures, etc.

This is implemented by adding a property called Prototype to the DynamicModel class
that contains delegates for each of the members of the prototype. The Query method
was modified so that every ExpandoObject returned will have all prototype members
added. An IDictionary containing the prototype members may be passed into the
DynamicModel constructor, or modified after instantiation by using the Prototype
property directly.

Added prototype feature
This is implemented by adding a property called Prototype to the DynamicModel class
that contains delegates for each of the members of the prototype. The Query method
was modified so that every ExpandoObject returned will have all prototype members
added.  An IDictionary containing the prototype members may be passed into the
DynamicModel constructor, or modified after instantiation by using the Prototype
property directly.

In general, this feature allows external tools to be developed to provide things
like automatic relationship fetching without actually extending the core Massive
codebase.  Another use would be for adding helper methods, validation routines, having
methods that correspond to specific store procedures, etc.
Contributor

robconery commented Mar 31, 2011

Looks interesting - but more than a sample project I'd love to see some tests. Doesn't have to be "massive" - either a console output or... ? I'm more keen on usability and how it runs etc.

Ok, I will put together some tests tonight. I also found a bug or two that I've fixed so I can add those as well. Thanks for taking a look!

@robconery robconery closed this Apr 27, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment