ef的多表联查
来源:互联网 发布:四个字的网络歌手名字 编辑:程序博客网 时间:2024/05/21 10:38
思路:用ef 进行关联一张表然后生成新的数据,然后在依次进行关联,整合查询自己想要的数据代码如下
1.引入命名空间
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.IO;using System.Xml;using System.Configuration;using System.Text;using System.Data;using System.Data.SqlClient;using Newtonsoft.Json;using System.Data.Entity.SqlServer;using System.Web.SessionState; // session
2.在一般处理程序中进行编写
public void ProcessRequest(HttpContext context) { context.Response.Clear(); context.Response.Write(GetGroupData(context).ToString()); context.Response.End(); }3.写逻辑
string ControllerName = context.Request.Form["ControllerName"].ToString(); string ActionName = context.Request.Form["ActionName"].ToString(); #region 开始处理 if (ControllerName == "StackDetail") { #region 用户部分登陆部分 if (ActionName == "LoadPagin") { return Recombination.RB_SinLogin(context); } #endregion }4.返回
var cbbs = Pcontext.P2Pcontact.Where(n => n.P2PcontactId == Id) .Join(Pcontext.ContType, m => m.P2PType, n => n.ContTypeId, (m, n) => new { P2PcontactId = m.P2PcontactId, UserCustomerId = m.UserCustomerId, CommentUrlId = m.CommentUrlId, TypeName = n.TypeName, //P2PType P2PDateContent = m.P2PDateContent, P2PDate = m.P2PDate, SignC = m.SignC, CRelationId = m.CRelationId, CRelationType = m.CRelationType }).Join(Pcontext.CommentUrl, m => m.CommentUrlId, n => n.CommentUrlId, (m, n) => new { P2PcontactId = m.P2PcontactId, UserCustomerId = m.UserCustomerId, CommentUrl1 = n.CommentUrl1, TypeName = m.TypeName, //P2PType P2PDateContent = m.P2PDateContent, P2PDate = m.P2PDate, SignC = m.SignC, CRelationId = m.CRelationId, CRelationType = m.CRelationType }).Join(Pcontext.UserCustomer, m => m.UserCustomerId, n => n.UserCustomerId, (m, n) => new { P2PcontactId = m.P2PcontactId, UserName = n.UserName, CommentUrl1 = m.CommentUrl1, TypeName = m.TypeName, //P2PType P2PDateContent = m.P2PDateContent, P2PDate = m.P2PDate, SignC = m.SignC, CRelationId = m.CRelationId, CRelationType = m.CRelationType }) .ToList(); return JsonConvert.SerializeObject(new { Count = 1, DBData = cbbs });
阅读全文
0 0
- ef的多表联查
- 【EF】 EF的一些错误和解决办法
- EF 小数位的保留
- 优化EF的性能
- EF的datetime2类型
- EF的高可用性
- EF的CRUD
- EF的使用建议
- EF的edmx文件
- EF的操作
- EF的分析
- 我的EF功能
- EF 的排序问题
- 强大的EF映射
- 【EF操作】——多表联查的linq操作
- ef
- EF
- EF
- 浏览器渲染原理
- HDOJ 1003题:max sum
- SIFT中的尺度空间和传统图像金字塔
- 安卓架构从mvc到mvp再到mvvm
- Integer.bitCount()理解
- ef的多表联查
- CCF201703-2 学生排队
- 子线程怎么传递数据给主线程
- R语言 绘制热图 pheatmap
- NKOJ 3777 卡牌操作(线段树)
- textContent和innerText属性的区别
- 快速排序 C++
- wpf的小问题实记1---TextBox无法拖入事件
- python备忘六:list 列表之列表基本特性