我有一个十进制数组BOOK_NO[]
。我有这样的查询:
PrintOrderList = (
from t1 in db.DIS_SET_PRINT_REQ
join t2 in db.RND_BOOK on t1.F_BOOK_NO equals t2.BOOK_NO into first_joined
where (t1.IS_EXIST == 1 &&
t1.F_COMPANY_NO == Company_No &&
@book_no.(t1.F_BOOK_NO))
from dept_data in first_joined.DefaultIfEmpty()
select new DIS_SET_PRINT_REQ_R_SINGLE_MODEL
{
BOOK_NO = dept_data.BOOK_NO,
BOOK_NAME = dept_data.BOOK_NAME,
EDITION_NAME = dept_data.RND_SET_BOOK_EDITION.BOOK_EDITION_NAME,
FISCAL_YEAR = t1.SNS_SET_FISCAL_YEAR.FISCAL_YEAR_NAME,
ACADEMIC_LEVEL = dept_data.RND_SET_BOOK_ACA_LEVEL.BOOK_ACA_LEVEL_NAME,
PRINT_QUANTITY = t1.BOOK_QTY,
PRINT_REQ_NO = t1.PRINT_REQ_NO,
PRINT_SEQ = (db.DIS_SET_PRINT_REQ_DTL.Where(x => x.F_PRINT_REQ_NO == t1.PRINT_REQ_NO)
.Where(x => x.IS_EXIST == 1)
.OrderBy(x => x.PRINT_REQ_DTL_NO)),
FISCAL_YEAR_NO = t1.F_FISCAL_YEAR_NO,
EDITION_NO = t1.RND_BOOK.F_BOOK_EDITION_NO,
ACADEMIC_LEVEL_NO = dept_data.RND_SET_BOOK_ACA_LEVEL.BOOK_ACA_LEVEL_NO,
CATEGORY_NO = dept_data.F_BOOK_CATEGORY_NO
}).ToList();
在这里,我需要设置BOOK_NO[]
包含任何t1.F_BOOK_NO
答案 0 :(得分:1)
使用.Contains
上的BOOK_NO[]
检查t1.BOOK_NO
是否在其中
PrintOrderList = (
from t1 in db.DIS_SET_PRINT_REQ
join t2 in db.RND_BOOK on t1.F_BOOK_NO equals t2.BOOK_NO into first_joined
where t1.IS_EXIST == 1 &&
t1.F_COMPANY_NO == Company_No &&
book_no.Contains(t1.F_BOOK_NO)
from dept_data in first_joined.DefaultIfEmpty()
select new DIS_SET_PRINT_REQ_R_SINGLE_MODEL
{
BOOK_NO = dept_data.BOOK_NO,
BOOK_NAME = dept_data.BOOK_NAME,
EDITION_NAME = dept_data.RND_SET_BOOK_EDITION.BOOK_EDITION_NAME,
FISCAL_YEAR = t1.SNS_SET_FISCAL_YEAR.FISCAL_YEAR_NAME,
ACADEMIC_LEVEL = dept_data.RND_SET_BOOK_ACA_LEVEL.BOOK_ACA_LEVEL_NAME,
PRINT_QUANTITY = t1.BOOK_QTY,
PRINT_REQ_NO = t1.PRINT_REQ_NO,
PRINT_SEQ = (db.DIS_SET_PRINT_REQ_DTL.Where(x => x.F_PRINT_REQ_NO == t1.PRINT_REQ_NO)
.Where(x => x.IS_EXIST == 1)
.OrderBy(x => x.PRINT_REQ_DTL_NO)),
FISCAL_YEAR_NO = t1.F_FISCAL_YEAR_NO,
EDITION_NO = t1.RND_BOOK.F_BOOK_EDITION_NO,
ACADEMIC_LEVEL_NO = dept_data.RND_SET_BOOK_ACA_LEVEL.BOOK_ACA_LEVEL_NO,
CATEGORY_NO = dept_data.F_BOOK_CATEGORY_NO
}).ToList();