EF 查询表数据,如果查询外键表,且这个外键有可能为空,但主表资料也就查不出来的解决方法
2013-08-20 10:53
281 查看
var items = from x in ctx.MES_Entity_RegisterMeasureES
join y in ctx.MES_Code_TypesFieldProduct on x.ProductTypeCode equals y.ProductTypeCode
into temp
from tt in temp.DefaultIfEmpty()
join z in ctx.MES_Entity_RegisterProductionUnits on x.ProductionUnitID equals z.ProductionUnitID
into temp1
from bb in temp1.DefaultIfEmpty()
select new RegisterMeasureESModel() { ProductionUnitName = bb.ProductionUnitName ,
ProductType=tt.ProductType };
join y in ctx.MES_Code_TypesFieldProduct on x.ProductTypeCode equals y.ProductTypeCode
into temp
from tt in temp.DefaultIfEmpty()
join z in ctx.MES_Entity_RegisterProductionUnits on x.ProductionUnitID equals z.ProductionUnitID
into temp1
from bb in temp1.DefaultIfEmpty()
select new RegisterMeasureESModel() { ProductionUnitName = bb.ProductionUnitName ,
ProductType=tt.ProductType };
相关文章推荐
- EF(Entity Framework)发生错误”正在创建模型,此时不可使用上下文“的解决办法。 正在创建模型,此时不可使用上下文。如果在 OnModelCreating 方法内使用上下文或如果多个线程同时访问同一上下文实例,可能引发此异常。请注意不保证 DbContext 的实例成员和相关类是线程安全的。 临时解决了这个问题,在Context的构造函数中,禁用了自动初始化:
- 归档model 里面的数据室, 不能归档数值型数据 或者 解归档不出来的解决方法
- plsql查询数据显示为乱码解决方法
- 如果使用Excel oledb 导数据出现各种错误的解决方法
- mysql查询中如果存在引号报错的问题解决方法
- 关于VS “ 警告 C4244 “参数”: 从“time_t”转换到“unsigned int”,可能丢失数据 ”的解决方法
- 使用Ef查询出现的问题The cast to value type 'System.Boolean' failed because the materialized value is null.的解决方法
- hibernate中查询出来的字段并不能自动转换为bean对象的解决方法
- Yii2 联表查询数据丢失,即出现主键覆盖情况的解决方法
- SQLSERVER 占了500多M内存,原来的程序无法一次查询出50多W数据了,记录下这个问题的解决过程。
- plsql查询数据显示为乱码解决方法
- MYSQL 不允许在子查询的同时删除原表数据的解决方法
- “在应用程序级别之外使用注册为 allowDefinition=’MachineToApplication’ 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误”的解决方法
- mybatis中模糊查询时一个字段匹配不定量数据解决方法
- shiny运行如果出现致命错误的可能解决方法
- 数据库中导出CSV文件与EXCEL文件数据对比可能遇到的问题与解决方法
- Access模糊查询查不到数据的解决方法
- jdbc查询大量数据内存溢出的解决方法
- php查询mysql大量数据造成内存不足的解决方法
- php连接sql server查询text字段丢失数据解决方法