我有两个问题。
- I been reading in nhibernate beginners guide 3 about using auto mapper with fluent. I read about this before(and I use auto mapper in my project already) however I am still not sure about a couple things.
当你需要像诺尔(No.Null)()那样做,或不得不花一定时间,或反之。 你们如何建立这些联系? 你们不得不为有这些环境的每一种财产建立自动测绘台? 是否有这种违约的目的?
- I also been reading about common mistakes and one mistake was talking about when you need readonly. I am actually suffering from this problem and had to make a fix that I was never that happy about.
从阅读这段话后,我很想知道,是否明智地绘制了两幅我只读的那几类地图。
Say I have this
public PlanMap()
{
Table("Plans");
Id(x => x.Id);
Map(x => x.Name).Not.Nullable().NvarcharWithMaxSize();
Map(x => x.Description).Not.Nullable().NvarcharWithMaxSize();
Map(x => x.Price).Not.Nullable();
Map(x => x.Discount).Not.Nullable();
Map(x => x.LengthInMonths).Not.Nullable();
References(x => x.Role).Not.Nullable();
HasMany(x => x.Students).Cascade.All();
}
这样做是明智的。
public ReadOnlyPlanMap()
{
Table("Plans");
ReadOnly();
SchemaAction.None();
Id(x => x.Id);
Map(x => x.Name).Not.Nullable().NvarcharWithMaxSize();
Map(x => x.Description).Not.Nullable().NvarcharWithMaxSize();
Map(x => x.Price).Not.Nullable();
Map(x => x.Discount).Not.Nullable();
Map(x => x.LengthInMonths).Not.Nullable();
References(x => x.Role).Not.Nullable();
HasMany(x => x.Students).Cascade.All();
}
然后,当我不使用其他地图时,我需要阅读吗? 我认为这是错误的唯一东西是重复法。 我不敢肯定,我是否能够利用遗产或东西来解决这个问题。
3. 。 我在书中读到,它建议不要在你的数据库中使用“阿托特”加固办法,而是在原地使用一个hi子处理。
In the book it says if you did something like session.Save(object);
it would actually go and contact the server and this would break the unit of work. Does this happen when "auto" incrementing is set on the database? I never saw evidence of that happening and actually I had to commit a record before I would actually see the id.
当你使用hi-lo时,哪类数据是你的一栏? 我通常用墨水加固。 难道我还是用了吗?
最后,从几个例子开始 我看到,他们通常把自己的PK财产当作这样的财产。
public virtual int Id { get; private set; }
然而,在书本中,我不断看到
public virtual int Id { get; set; }
我认为,使用私人套是阻止人们为科索沃警察部队自食其力的途径。