Я не могу определить отображение кода для 2 связанных объектов (Asset и AssetType). У объекта Asset есть только один AssetType. У AssetType есть много Активов. Я хочу иметь заголовок, емкость, комиссию из актива вместе с типом из AssetType. Ниже представлены сущности. Asset.csОтображение кодов NHibernate
public class Asset
{
public virtual int ID { get; set; }
public virtual string Title { get; set; }
public virtual decimal Fee { get; set; }
public virtual int Capacity { get; set; }
public virtual int AssetTypeID { get; set; }
public virtual AssetType AssetType { get; set; }
}
public class AssetMap : ClassMapping<Asset>
{
public AssetMap()
{
Table("Asset");
Id(x => x.ID, x => x.Generator(Generators.Identity));
Property(x => x.Title, x => x.NotNullable(true));
Property(x => x.Fee, x => x.NotNullable(true));
Property(x => x.Capacity, x => x.NotNullable(true));
Property(x => x.AssetTypeID, x => x.NotNullable(true));
Bag(t => t.AssetType, t =>
{
t.Table("AssetType");
t.Key(k => k.Column("ID"));
}, t => t.OneToMany(k => k.Column("AssetTypeID")));
}
}
AssetType.cs
public class AssetType
{
public virtual int ID { get; set; }
public virtual string Type { get; set; }
public virtual IList<Asset> Assets { get; set; }
}
public class AssetTypeMap : ClassMapping<AssetType>
{
public AssetTypeMap()
{
//AssetType AssetType = null;
Table("AssetType");
Id(x => x.ID, x => x.Generator(Generators.Identity));
Property(x => x.Type, x => x.NotNullable(true));
ManyToOne(x => x.Assets, map => {
map.Column("ID"); map.Cascade(Cascade.All);
});
}
}
Это сообщение об ошибке:
Ошибка 1 Аргументы типа для метода «NHibernate.Mapping. ByCode.Impl.CustomizersImpl.PropertyContainerCustomizer.Bag (строка, Система. Действие>, System.Action>) ' не может быть выведено из использования. Попробуйте явно указать аргументы типа . C: \ Users \ Aatish \ Documents \ Visual Studio 2013 \ Projects \ EventPlanner \ Решения \ EventPlanner \ EventPlanner \ Models \ Asset.cs 32 13 EventPlanner
Спасибо