from t1 in table1 join t2 in table2 on t1.Id equals t2.Id into t2g from t2 in t2g.DefaultIfEmpty() join t3 in table3 on t2.Id equals t3.Id into t3g from t3 in t3g.DefaultIfEmpty() join t4 in table4 on t3.Id equals t4.Id into t4g from t4 in t4g.DefaultIfEmpty() select new { t1, t2, t3, t4 }
\ /// <summary> /// 将返回的集合转换成json /// </summary> /// <returns></returns> public static string GetListToJSON() { using (var context = new TestEntities1()) { var query = from tb in context.MType join tb2 in context.procdetor on tb.ID equals tb2.TypeID into tb2g from tb2 in tb2g.DefaultIfEmpty() join t3 in context.Sys_Users on tb2.createUserID equals t3.ID into t3g from t3 in t3g.DefaultIfEmpty() orderby tb2.createDatetime select new { ID = tb.ID, TypeID = tb2.TypeID, procName = tb2.procName, UserName = t3.UserName, createDatetime = tb2.createDatetime, createUserID = t3.ID, procdic = tb2.procdic, price = tb2.price
};
//select new //{ // ID = tb.ID, // TypeID = tb.TypeID, // procName = tb.procName, // UserName = tm.UserName, // createDatetime = tb.createDatetime, // createUserID = tm.ID, // procdic = tb.procdic, // price=tb.price // // TypeName = "暂无" //}; return EntityToJSON.ToEntitiesJson(query.Skip(0).Take(5)); } }
|