Created
November 15, 2011 15:51
-
-
Save JoshClose/1367399 to your computer and use it in GitHub Desktop.
The New World of NHibernate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This: | |
session.CreateCriteria( typeof( MyClass ) ).Add( Expression.Eq( "Name", name ) ); | |
// Becomes this: | |
session.CreateCriteria( typeof( MyClass ) ).Add<MyClass>( m => m.Name == name ).List(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass | |
{ | |
public virtual int? Id { get; private set; } | |
public virtual string Name { get; set; } | |
public virtual MyReference MyReference { get; set; } | |
public virtual IList<MyReference> MyReferenceCollection { get; private set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClassMap : ClassMap<MyClass> | |
{ | |
public MyClassMap() | |
{ | |
Id( m => m.Id ); | |
Map( m => m.Name ); | |
References( m => m.MyReference ); | |
HasMany( m => m.MyReferenceCollection ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment