1
Vote

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

description

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
 
e.g.
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.
e.g.
  1. <col1>And<col2>And<col3>
  2. <col1>Or<col2>Or<col3>
     
     
    e.g.
    User user = User.Find.ByFirstNameAndLastName( "john", "doe");
    User user = User.Find.ByUserIdOrEmail("user1", "user1@mail.com");

file attachments

comments

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.