我试图使用StructureMap初始化我从ApiController派生的ValuesController,但我得到一个异常,说:
IControllerFactory'... CustomControllerFactory'没有返回名称'api'的控制器.
这是代码..
public class CustomControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
if (controllerType == null)
return null;
return (Controller)ConcretizationsManager.GetInstance(controllerType);
}
}
Run Code Online (Sandbox Code Playgroud)
基本上ConcretizationsManager是StructureMap的包装器.这个方法对于Controller类型的控制器总是运行正常,但是对于APIController不行.
有人让我走向正确的方向吗?很感谢
我有NxN表,想象一下:
用户(id,...)< - UserAddresses(id,userId,addressId,enabled,...) - >地址(id,...)
UserAddresses包含用户和地址的FK.据我所知,实体框架用户创建的实体包含UserAddresses的集合.地址包含UserAddresses的集合,特定的UserAddress包含对User和一个Address的重新发送.
现在我想通过linq进行下一个查询.对于特定用户标识,仅获取已启用标志设置为true的userAddresses.对于特定用户标识,userAddresses可以包含多个条目,但只为此特定用户设置了一个条目.
我能做的查询是:
context.User.Include( x => x.UserAddresses )
.Include( x => x.UserAddresses.Select(y => y.Address) )
.Single( x => x.id == USER_ID )
Run Code Online (Sandbox Code Playgroud)
但我真正想要的是不为该用户加载所有UserAddresses ...只包含启用的那个,设置为TRUE!
有人可以帮我做这个查询吗?
我正在用3层的asp.net网络表单开发一个网站;UI,BLL和DAL网站已经开发,但我希望对每种形式的单元测试有更多控制权
我认为,无论应用程序是否存活,在特定的输入处传递特定的值。
我已经研究过NUnit,但是在UI层的Webforms中如何应用这些测试?
我所拥有的是某种方法来测试UI(验证),而不必像我是用户那样访问BLL。
我正在尝试将单元测试添加到我的应用程序中,但是我不确定该怎么做!
有人可以帮助我解决更大的问题吗?
我想访问我的 sql 数据库,而不是放置在ASUS\MSSQLSERVER1数据库名称“Test”中,并使用密码 teste 访问用户 teste
在 Java 代码中,我对此进行了编码:
@Test
public void TesteTemp() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException
{
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String connString = "jdbc:jtds:sqlserver://ASUS/Test;instance=MSSQLSERVER1;user=teste;password=teste;";
Connection conn = null;
try{
conn = DriverManager.getConnection(connString);
}catch(SQLException ex){
ex.printStackTrace();
}
conn.close();
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
服务器 ASUS 没有名为 MSSQLSERVER1 的实例。
这说得通?
我正在运行 MSSQLSERVER1 服务。
我们,在asp转发器服务器控件上不存在数据绑定事件?
我只是想绑定我的所有数据,并在最后创建一个新的ItemTemplate并添加它,但只是什么时候所有数据绑定