我使用StructureMap做了一点工作,我设法在我的控制器中注入(通过构造函数注入)一个接口的具体类型存储库.
现在,我需要将存储库类型注入我的自定义成员资格提供程序.但是怎么样?我的自定义成员资格提供程序是通过Membership.Provider.ValidateUser(例如)创建的.
对于控制器我创建了一个这样的类:
public class IocControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(
System.Web.Routing.RequestContext requestContext,
Type controllerType)
{
return (Controller)
ObjectFactory.GetInstance(controllerType);
}
}
Run Code Online (Sandbox Code Playgroud)
并在Global.asax在Application_Start():
//...
ObjectFactory.Initialize(x =>
{
x.AddRegistry(new ArticleRegistry());
}
);
ControllerBuilder.Current.SetControllerFactory(
new IocControllerFactory());
//...
Run Code Online (Sandbox Code Playgroud)
但是如何使用StructureMap在我的自定义成员资格提供程序中注入具体类型?
c# structuremap asp.net-mvc membership-provider asp.net-mvc-2
我需要使用jdbc 4.0从java连接到Sql Server 2008 .我有一个非常简单的代码:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost;" +
"integratedSecurity=true;";
Connection con = DriverManager.getConnection(connectionUrl);
Run Code Online (Sandbox Code Playgroud)
但我有这个错误:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at …Run Code Online (Sandbox Code Playgroud) 在本书应用领域驱动设计在C#示例在第4章(第一个素描)上点4.并发冲突检测是非常重要的,我不明白为什么笔者有选择这个aggregates.Customer有他自己的骨料和秩序有他自己的聚合.
我认为客户应该参考他的订单.
订单只与客户有身份.我没有看到一个情况是通过他的id从数据库获得订单.但是如果我应用这个逻辑,那么在我的域模型中,我几乎没有包含所有实体和值对象的复杂聚合.我不想要这个.
从数据库获取客户时,它不会直接加载他的订单(延迟加载).所以这不是一个论点.
如果客户在不同的场景中使用,那么最好清除客户的参考仅在一个场景中有用.我想这是为订单汇总并对其订单进行"间接参考"的一个原因.
那么选择聚合的真正原因是什么?
我有另一个误解.订单有更多OrderLine.OrderLine有一个产品.为什么允许OrderLine在聚合顺序之外引用对象(Product)?
如果指定没有时间组件的日期值,则默认时间为午夜.如果指定没有日期的日期值,则默认日期是当前月份的第一天.
Oracle DATE列始终包含日期和时间的字段.如果查询使用的日期格式没有时间部分,则必须确保DATE列中的时间字段设置为午夜.
解决方案是使用日期数据类型对列进行约束,并TRUNC()在插入或更新表中的行时创建触发器(with ).
如果我使用这个解决方案,我是否有保证,Oracle确实为没有时间的日期存储更少的字节?
使用此标准日期时间类型Oracle会产生歧义.创建日期类型(仅包含日期)非常困难?这是我的观点(我来自MSSQL).
c# ×2
asp.net-mvc ×1
date ×1
java ×1
jdbc ×1
netbeans ×1
netbeans-7 ×1
oracle ×1
oracle11g ×1
structuremap ×1