我一直在寻找,但我还没有找到解决这个问题的方法:我想创建一个类库,该类库在名为Configuration的子目录下有一个配置文件.我希望将该类库部署到任何地方,我希望它通过了解自己的位置来查找其配置文件.
以前的尝试Assembly.GetExecutingAssembly().Location
没有奏效.
它会返回临时位置,例如
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7c00e0a3\38789d63\assembly\dl3\9c0a23ff\18fb5feb_6ac3c901
而不是期望的
bin/Configuration
路径.
所以:
我无法更新以前创建的实体.我收到一条StaleObjectException
带有消息的异常:
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Project.DomainLayer.Entities.Employee#00000000-0000-0000-0000-000000000000]
我不与任何人分享更新过程.有什么问题?
数据访问/ DI
public class DataAccessModule : Ninject.Modules.NinjectModule
{
public override void Load()
{
this.Bind<ISessionFactory>()
.ToMethod(c => new Configuration().Configure().BuildSessionFactory())
.InSingletonScope();
this.Bind<ISession>()
.ToMethod(ctx => ctx.Kernel.TryGet<ISessionFactory>().OpenSession())
.InRequestScope();
this.Bind(typeof(IRepository<>)).To(typeof(Repository<>))
.InRequestScope();
}
}
Run Code Online (Sandbox Code Playgroud)
数据访问/映射
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Project.DomainLayer" namespace="Project.DomainLayer.Entities">
<class name="Employee" optimistic-lock="version">
<id name="ID" column="EmployeeID" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid.comb" />
</id>
<version name="Version" type="Int32" column="Version" />
<!-- properties -->
<property name="EmployeeNumber" />
<!-- ... --> …
Run Code Online (Sandbox Code Playgroud) 我选择将其mongodb
用作以域为中心的数据的存储.我正在寻找official mongodb providers
将它们集成到ASP.NET MVC
项目中以保留单个应用程序数据库.没有官方提供商,可用的提供商看起来不成熟/稳定.所以我决定使用简单的会员资格.
Entity Framework
如果可能的话,如何摆脱特定的代码AccountController
?
如何管理具有SimpleMembership UserProfile
和MongoDB
User
?的用户配置文件?
例
在单独的程序[project-name].domain
集中有两个类:
public class Event {
public DateTime ScheduledDate { get; set; }
public String Name { get; set; }
public Location Location { get; set; }
}
public class User {
public String Name { get; set; }
public List<Events> AssociatedEvents { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如果我添加一个UserProfileId
,这将是一个解决方案User
吗?
public class …
Run Code Online (Sandbox Code Playgroud) 有一项任务与改变实体的状态有关.我很困惑,想一想它是否应该是一个基于事件的方法,它涉及到类似的东西,CQRS
或者我可以使用a State pattern
并将所有逻辑留在实体中.
我发现了一篇文章,其中显示了使用状态模式的域模型(或其中一部分):http://www.prowareness.com/blog/?p = 1448
订购系统与我的域模型非常接近.所以这个例子很棒.但是我仍然想知道考虑MVC模式是否是一个好的做法,是否可以实现RavenDB/NHibernate
?
编辑:问题重新考虑
让我们按照例子:
首先,这是一个名为的域名实体Idea
:
[Serializable]
public class Idea : AbstractEntity<Guid> {
private static IStateFactory stateFactory;
private AbstractState state = new InitiatedState();
[Required, StringLength(150)]
public String Title { get; set; }
[Required]
public String ProblemContext { get; set; }
public DateTime CreatedOn { get; set; }
public Guid InitiatorId { get; set; }
[Required]
public Decimal InvestmentAmount { get; set; }
public Boolean …
Run Code Online (Sandbox Code Playgroud) nhibernate asp.net-mvc design-patterns domain-driven-design ravendb
如何将EVENT_DATE_B - EVENT_DATE_A
多少天转换成字符串HH:MM
格式?
在我们的Core域模型设计中,我们有一个名为"Category"的类,其构造函数是内部设计的.由于构造函数是内部的,因此在编写单元测试用例时,我将无法创建"类别"对象.
所以我的问题是,将构造函数公开以使"类别"类可测试是最佳做法吗?或者我不应该测试"类别",而应该测试负责创建此对象的类/方法?
钽,
Rajeesh
考虑下图:
思念
问题
proc_open
,curl
方法.我没有得到如何使用消息队列(如果它适用的话).笔记
只是告诉我我正在使用Windows OS(Windows Server 2008
)和XAMPP
考虑一下情况:
public class OrderController {
IBus bus;
public OrderController(IBus bus) {
this.bus = bus;
}
public ActionResult Checkout(String orderId) {
var command = new CheckoutOrderCommand(orderId);
bus.Send(command);
return Redirect("on-success-url");
}
}
Run Code Online (Sandbox Code Playgroud)
相应的命令处理程序(在单独的程序集中定义)正在等待处理的incomming消息.
但是我们已经说过发送一切都好
return Redirect("on-success-url");
如果处理程序无法保存对域的更改,该怎么办?
好吧,可以在命令处理程序端使用队列来发布响应,以将Web应用程序订阅到队列.
最终用户如何获得即时/同步ui响应,这将反映对域的实际更改?我应该这样做吗?
通过消息总线处理命令是否仅适用于没有确认的后台任务?
让我们假设我们得到以下内容:
A)工厂界面如
public interface IEmployeeFactory
{
IEmployee CreateEmployee(Person person, Constants.EmployeeType type, DateTime hiredate);
}
Run Code Online (Sandbox Code Playgroud)
B)混凝土工厂如
public sealed class EmployeeFactory : Interfaces.IEmployeeFactory
{
public Interfaces.IEmployee CreateEmployee(Person person, Constants.EmployeeType type, DateTime hiredate)
{
switch(type)
{
case BusinessObjects.Common.Constants.EmployeeType.MANAGER:
{
return new Concrete.Manager(person, hiredate);
}
case BusinessObjects.Common.Constants.EmployeeType.SALES:
{
return new Concrete.Sales(person, hiredate);
}
default:
{
throw new ArgumentException("Invalid employee type");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
C)员工家庭:Manager
与Sales
从一个抽象的员工继承.
更多关于我的简单建筑
一些客户端代码
public sealed class EmployeeFactoryClient
{
private Interfaces.IEmployeeFactory factory;
private IDictionary<String, Interfaces.IEmployee> employees;
public …
Run Code Online (Sandbox Code Playgroud) 我需要构建一个反映每天列车运行情况的图表。像这样的东西:
我从来没有建立过这样的图表。你知道我应该从什么开始吗?我找到了一个图形库,d3.js
但还没有使用它的经验。
你能指导我一点吗?
谢谢!
c# ×6
asp.net-mvc ×3
nhibernate ×2
asp.net ×1
asynchronous ×1
cqrs ×1
d3.js ×1
exception ×1
filepath ×1
formatting ×1
graph ×1
interface ×1
javascript ×1
masstransit ×1
messaging ×1
mongodb ×1
oracle ×1
orm ×1
path ×1
php ×1
ravendb ×1
sql ×1
sql-server ×1
svg ×1
tdd ×1
unit-testing ×1
windows ×1