//var ediReturnQuery = db.Set<BBAC_SE_DETAIL>().FromSqlRaw("SELECT a.* FROM Set_BBAC_SE_DETAIL a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace");
varediReturnQuery=db.Set<BBAC_SE_EDI>().FromSqlRaw("select * from (SELECT a.* FROM [dbo].[Set_BBAC_SE_EDI] a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveSeData=1) c where c.id is not null");
varseReturnQuery=db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select * from (SELECT a.* FROM [dbo].[Set_BBAC_SE_DETAIL] a right join (select PN,CustomerPartCodeNoSpace,COUNT(*) as hj,sum(Qty) as Qty,sum(CAST(IsHaveEdiData AS int)) as haveedi from Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having count(*)>sum(CAST(IsHaveEdiData AS int)) and count(*)>=3 and sum(CAST(IsHaveEdiData AS int))>=1) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveEdiData=0) c where c.id is not null ");
//var ediReturnQuery = db.Set<BBAC_SE_DETAIL>().FromSqlRaw("SELECT a.* FROM Set_BBAC_SE_DETAIL a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace");
varseReturnEntities=seReturnQuery.ToList();
varediReturnQuery=db.Set<BBAC_SE_EDI>().FromSqlRaw("select * from (SELECT a.* FROM [dbo].[Set_BBAC_SE_EDI] a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveSeData=1) c where c.id is not null");
varseReturnQuery=db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select * from (SELECT a.* FROM [dbo].[Set_BBAC_SE_DETAIL] a right join (select PN,CustomerPartCodeNoSpace,COUNT(*) as hj,sum(Qty) as Qty,sum(CAST(IsHaveEdiData AS int)) as haveedi from Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having count(*)>sum(CAST(IsHaveEdiData AS int)) and count(*)>=3 and sum(CAST(IsHaveEdiData AS int))>=1) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveEdiData=0) c where c.id is not null ");