C# nhibernate中值对象的映射列表
我有一个模型房子,它有门的列表,门代表价值对象C# nhibernate中值对象的映射列表,c#,.net,nhibernate,nhibernate-mapping,mapping-by-code,C#,.net,Nhibernate,Nhibernate Mapping,Mapping By Code,我有一个模型房子,它有门的列表,门代表价值对象 public class House : Entity<Guid> { public int Id { get; set; } public List<Door> Doors { get; set; } ... public House(){ Doors = new List<Door>(); } } 我正在使用nhibernate代码映射方法,所以我在mapping
public class House : Entity<Guid>
{
public int Id { get; set; }
public List<Door> Doors { get; set; }
...
public House(){
Doors = new List<Door>();
}
}
我正在使用nhibernate代码映射方法,所以我在mapping House中进行了尝试
HouseMap.cs
DoorMap.cs
我在HouseMap.cs上出错了
Componentc=>c.Doors,DoorMap.Mapping
无法将LAMBDA表达式转换为类型“STRING”,因为它不是委托类型
我做错了什么?非列表值对象的其他映射很好。您应该确保为您的C实体使用接口:
public class House : Entity<Guid>
{
...
//public List<Door> Doors { get; set; }
public virtual IList<Door> Doors { get; set; }
以下是从上述链接中提取的其他可用设置:
public class DoorMap
{
public static Action<IComponentMapper<Door>> Mapping()
{
return c =>
{
c.Property(p => p.Number);
c.Property(p => p.Color);
};
}
}
public class House : Entity<Guid>
{
...
//public List<Door> Doors { get; set; }
public virtual IList<Door> Doors { get; set; }
Bag(x => x.Doors, c =>
{
...
c.Fetch(CollectionFetchMode.Join); // or CollectionFetchMode.Select
// , CollectionFetchMode.Subselect
c.BatchSize(100);
c.Lazy(CollectionLazy.Lazy); // or CollectionLazy.NoLazy, CollectionLazy.Extra
c.Table("tableName");
c.Schema("schemaName");
c.Catalog("catalogName");
c.Cascade(Cascade.All);
c.Inverse(true);
c.Where("SQL command");
c.Filter("filterName", f => f.Condition("condition"));
c.OrderBy(x => x.Name); // or SQL expression
c.Access(Accessor.Field);
c.Sort<CustomComparer>();
c.Type<CustomType>();
c.Persister<CustomPersister>();
c.OptimisticLock(true);
c.Mutable(true);
...