Skip to content

erikojebo/nhibernate.dynamic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

NHibernate.Dynamic includes a dynamic repository base class which makes it
possible to perform dynamic, rails style, queries.

EXAMPLES:
Given the following class:

public class Parent
{
   public virtual int Id { get; set; }
   public virtual string Name { get; set; }
   public virtual string Address { get; set; }
   public virtual GrandParent GrandParent { get; set; }
   public virtual IList<Child> Children { get; set; }
}


If you want to load all parents with a given name with their children loaded:

var parents = _repository.GetByNameWithChildren("Name");

If you want to load a single entity, you can specify an id as the first parameter:

var parent = _repository.GetWithChildren(1);

or you can use GetOne instead of the Get prefix:

var parent = _repository.GetOneByName("Name");

Multiple relationships and filters can be combined with "And":

var parent = _repository.GetByNameAndAddressWithChildrenAndGrandParent("Name", "Address");


The code is very crude and quite simplistic. There are a number of performance
optimizations to make, so the number of queries is sub-optimal, but you'll get
the data you asked for.


RUNNING THE TESTS: 
The integration tests assume that there is a SQL Server
Express instance running at .\SQLEXPRESS with a database called
nhibernate.dynamic, that can be connected to using a trusted connection.

About

Helpers for NHibernate that use the dynamic features of C# 4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages