随笔分类 -  EntityFramework

EF
摘要:首先是ef的多数据库操作实现事务的方法 public int AddDifferenceDB(userinfo1 user1, userinfo user) { int result = 0; using (var test2DB = new test2Entities1()) { using (v 阅读全文
posted @ 2016-07-11 17:07 甜菜波波 阅读(7196) 评论(1) 推荐(0) 编辑
摘要:sql 版:SELECT [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate], [t0].[RequiredDate], [t0].[ShippedDate], [t0].[ShipVia], [t0].[Fr... 阅读全文
posted @ 2015-12-10 11:30 甜菜波波 阅读(2590) 评论(0) 推荐(0) 编辑
摘要:var customers = DB.Customer.Join(DB.Commission,cst => cst.CommissionId,com => com.CommissionId, (cst, com) => new Customer(){CommissionId = com.Commis... 阅读全文
posted @ 2015-12-09 18:54 甜菜波波 阅读(2018) 评论(0) 推荐(1) 编辑
摘要:[Key] //主键 [DatabaseGenerated(DatabaseGeneratedOption.Identity)] //设置自增 public int id { get; set; } [ForeignKey("catego... 阅读全文
posted @ 2015-09-23 11:21 甜菜波波 阅读(15528) 评论(0) 推荐(1) 编辑
摘要:ef join 用法var customers = DB.Customer.Join(DB.Commission,cst => cst.CommissionId,com => com.CommissionId, (cst, com) => new Customer(){CommissionId = ... 阅读全文
posted @ 2015-09-17 15:05 甜菜波波 阅读(764) 评论(0) 推荐(1) 编辑
摘要:1、左连接:var LeftJoin = from emp in ListOfEmployeesjoin dept in ListOfDepartmenton emp.DeptID equals dept.ID into JoinedEmpDeptfrom dept in JoinedEmpDept... 阅读全文
posted @ 2015-09-17 14:07 甜菜波波 阅读(936) 评论(0) 推荐(1) 编辑
摘要:EF分页代码using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public part... 阅读全文
posted @ 2015-09-07 15:05 甜菜波波 阅读(353) 评论(0) 推荐(0) 编辑
摘要:,那么我们整个项目里面上下文的实例会有很多个,我们又遇到了多次,当我们在编程的时候遇到多的时候,一般我们就要想想能不能解决多这个问题。(2)这里我要说的是EF上下文怎么管理呢?很简单啦,就是要保证线程内唯一,所以这里我们就要进行修改BaseRepository类了。(3) 在这里BaseReposi... 阅读全文
posted @ 2015-08-17 17:47 甜菜波波 阅读(9357) 评论(0) 推荐(1) 编辑

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