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