我正在进行查询,我需要加入两个没有关系的表,并且只搜索子零售的记录== 1:
SELECT dbo.BILL_INFO.BILL_NUMBER,
dbo.BILL_INFO.BILL_DATE,
dbo.BILL_INFO_DETAIL.SERVICE_CODE,
dbo.BILL_INFO_DETAIL.SERVICE_FEE,
dbo.BILL_INFO_DETAIL.REQUESTED_QUANTITY
FROM dbo.BILL_INFO
INNER JOIN dbo.BILL_INFO_DETAIL
ON dbo.BILL_INFO.BILL_NUMBER = dbo.BILL_INFO_DETAIL.BILL_NUMBER
AND dbo.BILL_INFO.PAY_MODE_ID = dbo.BILL_INFO_DETAIL.PAY_MODE_ID
AND dbo.BILL_INFO.CASHIER_ID = dbo.BILL_INFO_DETAIL.CASHIER_ID
所以,BILL_INFO_DETAILs = 1
的所有记录我最终将使用EF:
var test = from billInfo in context.BILL_INFOS
join billInfoDetail in context.BILL_INFO_DETAILS
on new {billInfo.BILL_NUMBER, billInfo.PAY_MODE_ID, billInfo.CASHIER_ID}
equals new
{
billInfoDetail.BILL_NUMBER,
billInfoDetail.PAY_MODE_ID,
billInfoDetail.CASHIER_ID
}
where billInfo.REMARKS.Contains(passNumber.ToString())
select new
{
billInfo.BILL_NUMBER,
billInfo.BILL_DATE,
billInfoDetail.SERVICE_CODE,
billInfoDetail.SERVICE_FEE,
billInfoDetail.REQUESTED_QUANTITY
};
所以,如果BILL_INFO和BILL_INFO_DETAIL有关系,我会在where子句中说:w.BILL_INFO_DETAILS.Count()== 1(所有账单只有一个账单明细)
我怎么做这个,因为没有关系?