Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# nHibernate有许多连接表_C#_Fluent Nhibernate Mapping - Fatal编程技术网

C# nHibernate有许多连接表

C# nHibernate有许多连接表,c#,fluent-nhibernate-mapping,C#,Fluent Nhibernate Mapping,我正在尝试用联接表创建一对多关系,但我很难做到这一点。下面是C语言中的表结构、实体和映射# 创建表tbl\U配置 ( strCode uniqueidentifier default NEWID(), strName nvarchar(最大值)不为空, ..... 约束pk_配置主键(strCode) ) 创建表tbl_环境 ( strCode uniqueidentifier default NEWID(), strName nvarchar(15)不为空, strDescription nv

我正在尝试用联接表创建一对多关系,但我很难做到这一点。下面是C语言中的表结构、实体和映射#

创建表tbl\U配置
(
strCode uniqueidentifier default NEWID(),
strName nvarchar(最大值)不为空,
.....
约束pk_配置主键(strCode)
)
创建表tbl_环境
(
strCode uniqueidentifier default NEWID(),
strName nvarchar(15)不为空,
strDescription nvarchar(最大值)不为空
约束pk_环境主键(strCode)
)
创建表tbl_配置环境
(
strConfiguration uniqueidentifier不为空,
Strength环境唯一标识符不为空
约束pk_配置环境主键(strConfiguration,strenginement),
约束fk_配置环境配置外键(strConfiguration)引用tbl_配置(strCode),
约束fk_配置环境环境外键(强化环境)引用tbl_环境(strCode)
)
公共类配置实体
{
公共虚拟Guid strCode{get;set;}
公共虚拟字符串strName{get;set;}
.....
公共虚拟ISet集合环境{get;set;}
}
公共类环境实体
{
公共虚拟Guid strCode{get;set;}
公共虚拟字符串strName{get;set;}
公共虚拟字符串strDescription{get;set;}
}
公共类环境映射:类映射
{
公共环境地图()
{
表(“tbl_环境”);
Id(x=>x.strCode).GeneratedBy.Guid();
Map(x=>x.strName);
Map(x=>x.strDescription);
不是。懒汉();
}
}
公共类配置映射:类映射
{
公共配置映射()
{
表(“tbl_配置”);
Id(x=>x.strCode).GeneratedBy.Guid();
Map(x=>x.strName);
加入(“tbl_配置环境”,m=>
{
m、 Fetch.Join();
m、 KeyColumn(“strConfiguration”);
m、 有许多(x=>x.colenvironment)
1.资产()
.Cascade.All()
.KeyColumn(“strCode”)
.Fetch.Join()
.Not.LazyLoad();
});
不是。懒汉();
}
}
根据我在控制台上看到的内容,它正确地映射了tbl_配置和tbl_配置环境之间的关系

tbl_配置11_左外连接 tbl_配置环境确认 confi11_u.strCode=confi11_1_u.strConfiguration

但是,它没有正确设置tbl_环境和tbl_配置环境之间的关系

左外连接tbl_环境colenviron12_uON confi11\ strCode=colenviron12\ strCode

相反,它在tbl_配置和tbl_环境之间建立了关系 我很确定错误在ConfigurationMap上,特别是在这一部分:

 m.HasMany<EnvironmentEntity>(x => x.colEnvironments)
                .AsSet()
                .Cascade.All()
                .KeyColumn("strCode")
                .Fetch.Join()
                .Not.LazyLoad();
        });
m.HasMany(x=>x.colenvironment)
1.资产()
.Cascade.All()
.KeyColumn(“strCode”)
.Fetch.Join()
.Not.LazyLoad();
});

您知道如何指定tbl_配置环境.strength环境之间的关系吗?我尝试使用.PropertyRef(“StrengerEnvironment”),但是当我这样做时,它看起来tbl_配置上的属性不正确

这不是一对多而是多对多。有帮助吗?是的,这是一个多对多的问题,但我在父项和子项引用中也有同样的错误,这就是为什么我要这样做。
 m.HasMany<EnvironmentEntity>(x => x.colEnvironments)
                .AsSet()
                .Cascade.All()
                .KeyColumn("strCode")
                .Fetch.Join()
                .Not.LazyLoad();
        });