2013年7月19日

Entity Framework:如果允许模型处于非法状态,在某些场景下,记得清空DbContext

摘要: 背景之前写过两篇文章介绍模型的合法性:DDD:关于模型的合法性,Entity.IsValid()合理吗?.NET:关于数据模型、领域模型和视图模型的一些思考今天讨论的问题其实是关于“主键映射”的,只是其中还涉及一种决策:“允许模型处于非常状态”。测试代码 1 public static void Do() 2 { 3 Database.SetInitializer(new DropCreateDatabaseAlways()); 4 5 using (var context = new MyDbContext()... 阅读全文

posted @ 2013-07-19 13:07 幸福框架 阅读(1471) 评论(0) 推荐(0) 编辑

.NET:为什么不能在子类或外部发布C#事件

摘要: 背景一个朋友问了一个问题:“为什么不能在子类或外部发布C#事件?”,我说我不知道,要看看生产的IL代码,下面我们看看。测试代码 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace EventStudy 8 { 9 class Program10 {11 static void Main(string[] args)12 ... 阅读全文

posted @ 2013-07-19 00:09 幸福框架 阅读(2138) 评论(17) 推荐(2) 编辑

导航

我要啦免费统计