//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");
varediReturnQuery=db.Set<BBAC_SE_EDI>().FromSqlRaw("select * from (SELECT distinct 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 ");
varseReturnQuery=db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select * from (SELECT distinct 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 ");
varseFlagErrQuery=db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select distinct a.* from [BQ_SA].[dbo].[Set_BBAC_SE_DETAIL] a left join [BQ_SA].[dbo].[Set_BBAC_SE_EDI] b on a.PN=b.PN and a.CustomerPartCodeNoSpace= b.CustomerPartCodeNoSpace where a.BusinessType=1 and a.IsHaveEdiData=0 and b.IsHaveSeData=1 and b.IsDeleted=0");
varediFlagErrQuery=db.Set<BBAC_SE_EDI>().FromSqlRaw("select distinct a.* from [dbo].[Set_BBAC_SE_EDI] a left join [dbo].[Set_BBAC_SE_DETAIL] b on a.PN=b.PN and a.CustomerPartCodeNoSpace= b.CustomerPartCodeNoSpace where a.IsHaveSeData=0 and a.IsDeleted=0 and b.BusinessType=1 and b.IsHaveEdiData=1");