gpt4 book ai didi

fluent-nhibernate - NHibernate映射异常: An association from the table dbo. AccountGroup引用了未映射的类: System.字符串

转载 作者:行者123 更新时间:2023-12-03 23:40:14 24 4
gpt4 key购买 nike

我收到此错误:

表dbo.AccountGroup中的关联引用了未映射的类:System.String

这是我的实体:

public class AccountGroup
{
public virtual int Id { get; private set; }
public virtual string Name { get; set; }
public virtual string Parent { get; set; }
public virtual string Description { get; set; }
public virtual IList<Account> Accounts { get; set; }

public AccountGroup()
{
this.Accounts = new List<Account>();
}
}

public class Account
{
public virtual int Id { get; private set; }
public virtual string Code { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual int Category { get; set; }
public virtual AccountGroup Group { get; set; }
public virtual IList<LedgerEntry> LedgerEntries { get; set; }

public Account()
{
this.LedgerEntries = new List<LedgerEntry>();
}
}

这是我的映射:
    public AccountGroupMap()
{
Table("dbo.AccountGroup");
Id(x => x.Id)
.Column("Id");
Map(x => x.Name);
References(x => x.Parent)
.Column("Parent");
Map(x => x.Description);
HasMany(x => x.Accounts)
.KeyColumn("GroupId")
.Inverse()
.Cascade.All();
}
}

public AccountMap()
{
Table("dbo.Account");
Id(x => x.Id)
.Column("Id");
Map(x => x.Code);
Map(x => x.Name);
Map(x => x.Description);
Map(x => x.Category);
References(x => x.Group)
.Column("AccountGroupId");
HasMany(x => x.LedgerEntries)
.KeyColumn("AccountId")
.Inverse()
.Cascade.All();
}

这是我的 table :

创建表AccountGroup
(
ID int PRIMARY KEY,
名称varchar(20),
父级int,
说明varchar(20)
)

创建表帐户
(
ID int PRIMARY KEY,
代码varchar(30),
名称varchar(20),
说明varchar(20),
类别int,
AccountGroupId int,
外键(AccountGroupId)引用AccountGroup(Id)
)

最佳答案

你有

References(x => x.Parent)
.Column("Parent");

当父级定义为
public virtual string Parent { get; set; }

您不能引用字符串(除非它是一个collection元素)

关于fluent-nhibernate - NHibernate映射异常: An association from the table dbo. AccountGroup引用了未映射的类: System.字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1826380/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com