10 2011 档案

摘要:Why compiled views?First of all I prefer VS.NET to compile the cshtml code at build time because it will notice syntax errors like on any .cs file. Syntax errors are most important when I have to do a quick check-in of all my sources to repository and I need to make sure I will not crash the next te 阅读全文
posted @ 2011-10-13 10:47 ido 阅读(574) 评论(0) 推荐(0) 编辑
摘要:http://msdn.microsoft.com/en-us/library/bb738523.aspxThis topic provides an example of how to define a transaction that coordinates making changes to objects in an object context with other external operations. For more information, see Managing Connections and Transactions. The example in this t... 阅读全文
posted @ 2011-10-11 10:39 ido 阅读(1045) 评论(0) 推荐(0) 编辑
摘要:Most of the time the Entity Framework (EF) can manage transactions for you. Every time you Add an Entity, Delete an Entity, Change an Entity, Create a Relationship or Delete a Relationship in your .NET code, these changes are remembered by the EF, and when you call SaveChanges()these are convert... 阅读全文
posted @ 2011-10-11 10:36 ido 阅读(6660) 评论(2) 推荐(1) 编辑
摘要:在Entity Framework 中使用SaveChanges()是很频繁的,单次修改或删除数据后调用SaveChanges()返回影响记录数。要使用批量修改或者批量删除数据,就需要SaveChanges(false)+AcceptAllChanges()方法了。SaveChanges(false) 只是通知EF需要对数据库执行的操作,在内存中是属于挂起状态,在必要的时候是可以撤销的,比如AcceptAllChange()提交为真正成功,EF将撤销SaveChanges(false)的操作。而在处理分布式事务操作的时候,就有必要使用TransactionScope 来处理了,很多时候我们会这 阅读全文
posted @ 2011-10-10 14:56 ido 阅读(8642) 评论(0) 推荐(2) 编辑
摘要:继续为想使用Entity Framework的朋友在前面探路,分享的东西虽然技术含量不高,但都是经过实践检验的。在Entity Framework中使用事务很简单,将操作放在TransactionScope中,并通过Complete()方法提交事务即可。示例代码如下:using (BlogDbContext context = new BlogDbContext()){ using (TransactionScope transaction = new TransactionScope()) { context.BlogPosts.Add(blogPost); ... 阅读全文
posted @ 2011-10-10 14:20 ido 阅读(780) 评论(0) 推荐(1) 编辑
摘要:Entity Framework 阅读全文
posted @ 2011-10-10 10:54 ido 阅读(5143) 评论(3) 推荐(2) 编辑

点击右上角即可分享
微信分享提示