English 中文(简体)
合成 原因 无法汇编制图文件的错误
原标题:CompositeId causes Could not compile the mapping document error

I am trying to use CompositeId to map to a legacy system. The source database has a composite primary key so I can t use the normal this.Id mapping.

这里,我试图把它描绘成:

public PriorityListPartMap()
{
    this.Schema("EngSchedule");

    this.Table("vPriorityListPart");

    this.CompositeId().KeyProperty(x => x.AssemblyPartNumber).KeyProperty(x => x.PartNumber);

    this.Map(x => x.CurrentDueDate);

    this.Map(x => x.OrderLine);

    this.Map(x => x.OrderNumber);

    this.Map(x => x.PartDescription);

    this.Map(x => x.ProductCode);

    this.Map(x => x.Revision);
}

When I try to create the session factory this mapping causes the error: Could not compile the mapping document: (XmlDocument)

I tried removing the CompositeId mapping and replaced it with:

this.Id(x => x.AssemblyPartNumber).GeneratedBy.Assigned();

这一错误与这种绘图相去甚远,但我可以实际利用,因为大会党并非独一无二。

是否有不同的办法绘制一个具有综合主要钥匙的表格?

Thanks,

Matthew MacFarland

最佳回答

“不汇编制图文件:(XmlDocument)”的内在例外是什么? 我的理论是,“集体补贴阶层必须优先于平等:青年平等党”。

对于需要复合产品的实体,该物体本身被用作钥匙。 为了同样得到承认的物体,你必须超越平等法和平等法。

举例来说,贵实体平等的方法就是这样:

public override bool Equals(object obj)
{
    var other = obj as PriorityListPart;

    if (ReferenceEquals(null, other)) return false;
    if (ReferenceEquals(this, other)) return true;

    return this.AssemblyPartNumber == other.AssemblyPartNumber &&
        this.PartNumber == other.PartNumber;
}

举例来说,贵实体的“GetHashCode”方法就是这样:

public override int GetHashCode()
{
    unchecked
    {
        int hash = GetType().GetHashCode();
        hash = (hash * 31) ^ AssemblyPartNumber.GetHashCode();
        hash = (hash * 31) ^ PartNumber.GetHashCode();

        return hash;
    }
}

这也意味着,如果你想要找回一个物体,那么你不可能有一个单一的钥匙。 为了适当检索特定物体及其复合关键部件,你使用的关键实际上就是标的,其组成部分是你希望检索的实体。

正因为如此,平等(平等)方法必须高于一切,因此,国家自由党能够根据你在平等方法中具体规定的内容,确定你实际试图收回哪些目标。

问题回答

暂无回答




相关问题
Does Fluent NHibernate support "trigger-identity"

I posted the question in the Fluent-NHibernate newgroup but so far there has been no answer from the void. Is there a Fluent NHibernate mapping for the NHibernate "trigger-identity" method of ...

automapping nested components naming conventions

Im making the switch from Fluent Mapping to Automapping in my current project. If I have the following domain: public class Matter{ public Client Client{get;set;} } public class Client { ...

NHibernate Search in a List using ICriteria

I have my class X : public class ClassX { public virtual IList<ClassY> ListY { get; set; } ... } My ClassX mapping (using Fluent) ... HasMany<ClassX>(x => x.ListY ) ....

Fluent nHibernate keeps recreating my database, why?

I m trying to convert my data layer from Linq2Sql to nHibernate. I think Xml the configuration in nHibernate is pretty backwards so I m using Fluent. I ve managed to get fluent, add in a repository ...

How to fluent-map this (using fluent nhibernate)?

I have two tables in my database "Styles" and "BannedStyles". They have a reference via the ItemNo. Now styles can be banned per store. So if style x is banned at store Y then its very possible that ...

热门标签