我有一个Parent类,它有两个子集合ChildCollectionA和ChildCollectionB.ChildCollectionA被映射为关联,并具有自己的ID:
HasMany(parent => parent.ChildCollectionA)
.KeyColumn("IDParent")
.AsBag().Cascade.AllDeleteOrphan();
Run Code Online (Sandbox Code Playgroud)
和ChildCollectionB映射有一个组件列表:
HasMany(parent => parent.ChildCollectionB)
.Table("ChildCollectionBTable")
.KeyColumn("IDParent")
.Component(m=>
{
m.References(childB => childB.Task, "IDTask").Not.LazyLoad().Not.Nullable();
m.Map(childB => childB.Date, "Date").Not.Nullable();
}
)
.AsBag().Cascade.AllDeleteOrphan();
Run Code Online (Sandbox Code Playgroud)
我现在需要DataBase中的所有Parent,因为我必须执行一些需要ChildCollectionA和ChildCollectionB的操作.
所以我不得不急于加载它们,我使用获取模式首先急切加载ChildCollectionA:
var queryParents = session.CreateCriteria().SetFetchMode("ChildCollectionA",FetchMode.Eager).Add(Expression.Le("ParentDate",endDate));
它返回492个父母(应该是481),我执行的操作的总价值是32,847.46€(应该是30,790.87€).所以我必须消除父副本:
var queryParents = session.CreateCriteria<Parent>()
.SetFetchMode("ChildCollectionA", FetchMode.Eager)
.Add(Expression.Le("ParentDate",endDate))
.SetResultTransformer(new DistinctRootEntityResultTransformer());
Run Code Online (Sandbox Code Playgroud)
我只用ChildCollectionB尝试了同样的热切加载
var queryParents = session.CreateCriteria<Parent>()
.SetFetchMode("ChildCollectionB", FetchMode.Eager)
.Add(Expression.Le("ParentDate",endDate))
.SetResultTransformer(new DistinctRootEntityResultTransformer());
Run Code Online (Sandbox Code Playgroud)
在这两种情况下返回481父母OK,价值为30,790.87€OK.
但是我需要同时加载两个集合,我这样做了:
var queryParents = session.CreateCriteria<Parent>()
.SetFetchMode("ChildCollectionA", FetchMode.Eager)
.SetFetchMode("ChildCollectionB", FetchMode.Eager)
.Add(Expression.Le("ParentDate",endDate))
.SetResultTransformer(new DistinctRootEntityResultTransformer());
Run Code Online (Sandbox Code Playgroud)
它返回了481个父母,价值为32,602.57欧元(应该是30,790.87欧元).
现在返回的父项数是正确的,但在其他地方有重复项,值取决于集合而不是父项,因此重复项必须位于ChildCollections中的某个位置.
现在我正在使用一个丑陋的解决方案:
var queryParents = session.CreateCriteria<Parent>()
.SetFetchMode("ChildCollectionA", FetchMode.Eager)
.Add(Expression.Le("ParentDate",endDate))
.SetResultTransformer(new DistinctRootEntityResultTransformer());
parents= queryParents.List<Parent>(); …Run Code Online (Sandbox Code Playgroud) 我在Apache中使用mod-mono托管ServiceStack Web服务,我有mono-3.0.0和xsp-2.10.2.我主持了针对.Net framework 2.0并使用mod-mono-server2的hello world示例,它运行良好.然后我将项目更改为目标.Net framework 4.0并使用mod-mono-server4.我收到此错误:
无法加载文件或程序集'System.Web.Extensions,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.该系统找不到指定的文件.
System.IO.FileNotFoundException:无法加载文件或程序集'System.Web.Extensions,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.该系统找不到指定的文件.文件名:'System.Web.Extensions,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35' 在System.AppDomain.Load(System.String assemblyString,System.Security.Policy.Evidence assemblySecurity,Boolean refonly)[0x00000] in:0 at System.AppDomain.Load(System.String assemblyString)[0x00000] in:0 at(at wrapper remoting-invoke-with-check)System.AppDomain:System.Reflection.Assembly.Load(System.String assemblyString)[0x00000]中的Load(string)in:0 at System.Web.Compilation.BuildManager.LoadAssembly(System. Web.Configuration.AssemblyInfo info,System.Collections.Generic.List`1 al)[0x00000] in:0,System.Web.Compilation.BuildManager.GetReferencedAssemblies()[0x00000] in:0,System.Web.Compilation.BuildManager .CallPreStartMethods()[0x00000] in:0
但是文件System.Web.Extensions安装在GAC中:
gacutil -l System.Web.Extensions
以下程序集安装在GAC中:System.Web.Extensions,Version = 1.0.61025.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35 System.Web.Extensions,Version = 3.5.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35 System.Web .Extensions,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35 items of items = …