我在层次结构中有以下对象A > B > C > D.每个对象都映射到一个表.我正在尝试使用QueryOver编写以下SQL:
SELECT B
FROM A, B, C, D
WHERE A.ID = B.ID
AND B.ID = C.ID
AND C.ID = D.ID
WHERE A.NUMBER = 'VALUE'
AND D.NAME IN ('VALUE1', 'VALUE2')
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有C#代码:
string[] entityNames = entityAttributes.Select(e => e.Name).ToArray();
string customerNumber = 2;
return session.QueryOver<B>()
.JoinQueryOver(b => b.C)
.JoinQueryOver(c => c.D)
.WhereRestrictionOn(d => d.Name).IsIn(entityNames)
.List<B>();
Run Code Online (Sandbox Code Playgroud)
这里缺少的是A > B链接.我无法弄清楚如何添加连接以A限制它在NUMBER字段上.我尝试了以下但是.JoinQueryOver(b => b.C)正在寻找类型A而不是寻找类型B.
return session.QueryOver<B>()
.JoinQueryOver(b …Run Code Online (Sandbox Code Playgroud) 目标:调整20个线程,这些线程将SessionFactory.GetSessionFactory(key)同时用于测试目的.(我正在尝试模拟ASP.NET等多线程环境)
问题:通过使用EndInvoke()方法,我实际上是GetSessionFactory(key)同步调用方法,还是我的代码在模拟多个线程GetSessionFactory(key)同时同时命中时是否正确?
谢谢,
凯尔
public void StressGetSessionFactory()
{
for (int i = 0; i < 20; i++)
{
Func<string, ISessionFactory> method = GetSessionFactory;
IAsyncResult asyncResult = method.BeginInvoke("RBDB", null, null);
ISessionFactory sessionFactory = method.EndInvoke(asyncResult); //My concern is with this call
Debug.WriteLine("RBDB ISessionFactory ID: " + sessionFactory.GetHashCode());
}
}
static ISessionFactory GetSessionFactory(string key)
{
return SessionFactory.GetSessionFactory(key);
}
Run Code Online (Sandbox Code Playgroud) 我一直在努力让ASP Web API/Autofac集成工作.我创建了一个简单的项目,其中一个Controller返回一个字符串,并且能够成功运行该应用程序.但是,当我将Autofac集成到解决方案中时,在运行时我会收到一个System.EntryPointNotFoundException: Entry point was not found.
以下是在我的机器上创建项目时包含的库版本(减去Autofac库).我从Nuget获得Autofac库,所有其他库都在本地安装.
我把Autofac代码放在我的Register方法中,如下所示:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
//Other code left out for brevity
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// Set the dependency resolver to be Autofac.
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
}
Run Code Online (Sandbox Code Playgroud)
我EntryPointNotFoundException在Application_Start方法中收到一个:
public class WebApiApplication …Run Code Online (Sandbox Code Playgroud)