public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
XML :
<? xml version ="1.0" encoding ="utf-8" ? >
< hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
namespace ="Eg" assembly ="Eg" >
< class name ="Customer" table ="Customers" >
< id name ="ID" >
< generator class ="identity" />
</ id >
< property name ="Name" />
< property name ="Credit" />
< bag name ="Products" table ="Products" >
< key column ="CustomerID" />
< one-to-many class ="Eg.Product, Eg" />
</ bag >
< component name ="Address" class ="Eg.Address, Eg" >
< property name ="AddressLine1" />
< property name ="AddressLine2" />
< property name ="CityName" />
< property name ="CountryName" />
</ component >
</ class >
</ hibernate-mapping >
, , :
[Test]
public void VerifyCustomerSaves()
{
new PersistenceSpecification<Customer>()
.CheckProperty(x => x.Name, "James Gregory" )
.CheckProperty(x => x.Age, 22)
.VerifyTheMappings();
}
, , . . .
http://code.google.com/p/fluent-nhibernate/
public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
XML :
<? xml version ="1.0" encoding ="utf-8" ? >
< hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
namespace ="Eg" assembly ="Eg" >
< class name ="Customer" table ="Customers" >
< id name ="ID" >
< generator class ="identity" />
</ id >
< property name ="Name" />
< property name ="Credit" />
< bag name ="Products" table ="Products" >
< key column ="CustomerID" />
< one-to-many class ="Eg.Product, Eg" />
</ bag >
< component name ="Address" class ="Eg.Address, Eg" >
< property name ="AddressLine1" />
< property name ="AddressLine2" />
< property name ="CityName" />
< property name ="CountryName" />
</ component >
</ class >
</ hibernate-mapping >
, , :
[Test]
public void VerifyCustomerSaves()
{
new PersistenceSpecification<Customer>()
.CheckProperty(x => x.Name, "James Gregory" )
.CheckProperty(x => x.Age, 22)
.VerifyTheMappings();
}
, , . . .
http://code.google.com/p/fluent-nhibernate/
public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
XML :
<? xml version ="1.0" encoding ="utf-8" ? >
< hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
namespace ="Eg" assembly ="Eg" >
< class name ="Customer" table ="Customers" >
< id name ="ID" >
< generator class ="identity" />
</ id >
< property name ="Name" />
< property name ="Credit" />
< bag name ="Products" table ="Products" >
< key column ="CustomerID" />
< one-to-many class ="Eg.Product, Eg" />
</ bag >
< component name ="Address" class ="Eg.Address, Eg" >
< property name ="AddressLine1" />
< property name ="AddressLine2" />
< property name ="CityName" />
< property name ="CountryName" />
</ component >
</ class >
</ hibernate-mapping >
, , :
[Test]
public void VerifyCustomerSaves()
{
new PersistenceSpecification<Customer>()
.CheckProperty(x => x.Name, "James Gregory" )
.CheckProperty(x => x.Age, 22)
.VerifyTheMappings();
}
, , . . .
http://code.google.com/p/fluent-nhibernate/
public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
XML :
<? xml version ="1.0" encoding ="utf-8" ? >
< hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
namespace ="Eg" assembly ="Eg" >
< class name ="Customer" table ="Customers" >
< id name ="ID" >
< generator class ="identity" />
</ id >
< property name ="Name" />
< property name ="Credit" />
< bag name ="Products" table ="Products" >
< key column ="CustomerID" />
< one-to-many class ="Eg.Product, Eg" />
</ bag >
< component name ="Address" class ="Eg.Address, Eg" >
< property name ="AddressLine1" />
< property name ="AddressLine2" />
< property name ="CityName" />
< property name ="CountryName" />
</ component >
</ class >
</ hibernate-mapping >
, , :
[Test]
public void VerifyCustomerSaves()
{
new PersistenceSpecification<Customer>()
.CheckProperty(x => x.Name, "James Gregory" )
.CheckProperty(x => x.Age, 22)
.VerifyTheMappings();
}
, , . . .
http://code.google.com/p/fluent-nhibernate/
public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
XML :
<? xml version ="1.0" encoding ="utf-8" ? >
< hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
namespace ="Eg" assembly ="Eg" >
< class name ="Customer" table ="Customers" >
< id name ="ID" >
< generator class ="identity" />
</ id >
< property name ="Name" />
< property name ="Credit" />
< bag name ="Products" table ="Products" >
< key column ="CustomerID" />
< one-to-many class ="Eg.Product, Eg" />
</ bag >
< component name ="Address" class ="Eg.Address, Eg" >
< property name ="AddressLine1" />
< property name ="AddressLine2" />
< property name ="CityName" />
< property name ="CountryName" />
</ component >
</ class >
</ hibernate-mapping >
, , :
[Test]
public void VerifyCustomerSaves()
{
new PersistenceSpecification<Customer>()
.CheckProperty(x => x.Name, "James Gregory" )
.CheckProperty(x => x.Age, 22)
.VerifyTheMappings();
}
, , . . .
http://code.google.com/p/fluent-nhibernate/
public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
XML :
<? xml version ="1.0" encoding ="utf-8" ? >
< hibernate-mapping xmlns ="urn:nhibernate-mapping-2.2"
namespace ="Eg" assembly ="Eg" >
< class name ="Customer" table ="Customers" >
< id name ="ID" >
< generator class ="identity" />
</ id >
< property name ="Name" />
< property name ="Credit" />
< bag name ="Products" table ="Products" >
< key column ="CustomerID" />
< one-to-many class ="Eg.Product, Eg" />
</ bag >
< component name ="Address" class ="Eg.Address, Eg" >
< property name ="AddressLine1" />
< property name ="AddressLine2" />
< property name ="CityName" />
< property name ="CountryName" />
</ component >
</ class >
</ hibernate-mapping >
, , :
[Test]
public void VerifyCustomerSaves()
{
new PersistenceSpecification<Customer>()
.CheckProperty(x => x.Name, "James Gregory" )
.CheckProperty(x => x.Age, 22)
.VerifyTheMappings();
}
, , . . .
http://code.google.com/p/fluent-nhibernate/
Source: https://habr.com/ru/post/38178/
All Articles