Expando object for ActiveRecord to allow dynamic findxxx methods such as "FindByTitleOrCateory"


This basically provides a ruby-rails like activerecord approach for find methods.
e.g. http://ar.rubyonrails.org/classes/ActiveRecord/Base.html
Dynamic attribute-based finders
User user = User.Find.ByFirstName("john");
User.FindAll.ByFirstNameAndLastName("john", "doe");
Support Operations Syntax
By<columnName1> ( And | Or ) <columnName2>( <columnName1_arg>, <columnName2_arg> )
Only And | Or are supported.
Can use multiple column filters but all the operators must be the same.
  1. <col1>And<col2>And<col3>
  2. <col1>Or<col2>Or<col3>
    User user = User.Find.ByFirstNameAndLastName( "john", "doe");
    User user = User.Find.ByUserIdOrEmail("user1", "user1@mail.com");

file attachments


rajeshgupthar wrote Oct 11, 2013 at 11:07 AM

Hi Kishore,
I have come up with a sample implementation of the requirement specified above.
I have also attached a patch of my changes done. (Im new to SVN hence, didnt know how to share the changes i have made to you before committing.)

Usage can be found in the EntityTests.cs file.

My implementation is based on the DynamicObject capabilities introduced in .net 4.0. Obviously, due to the nature of DynamicObject, intellisence support cannot be provided, But the implementation looks quite similar to the expectation.

Please comment on the patch, so that i will continue implementation of combination of And, Or stuff explained above.