سلام اساد من ازMyGenericRepository استفاده میکنم به این صورت
var DataSource = db.MelkForDetaill.Get(x =>x.MelkFor.Archive == 0 &&
(x.MelkFor.MelkType == combTypeProperty.Text|| x.MelkFor.MelkType == _MelkType || IsNullOrEmpty(combTypeProperty.Text))
&& (x.MelkFor.State == comboState.Text || IsNullOrEmpty(comboState.Text)) &&
(x.MelkFor.City == combCity.Text || IsNullOrEmpty(combCity.Text))
&& Areaali.Any(item => x.MelkFor.Area.Contains(item)) &&
(x.MelkFor.Documents == comboDocument.Text || IsNullOrEmpty(comboDocument.Text))
&& tview.Any(item => x.tview.Trim().Contains(item))
&& (IsNullOrEmpty(comboSelectaspect.Text) ||aspect.Any(item => x.MelkFor.aspect.Contains(item)))
&& (x.MelkFor.SalesPrices >= SalesPriceaz || IsNullOrEmpty(textSalesPriceaz.Text)) && (x.MelkFor.SalesPrices <= SalesPriceta || IsNullOrEmpty(textSalesPriceta.Text))
&& (x.MelkFor.Loan >= LoanAz || IsNullOrEmpty(textLoanAz.Text)) && (x.MelkFor.Loan <= LoanTa || IsNullOrEmpty(textLoanTa.Text))
&& (IsNullOrEmpty(ComboLicenseStatus.Text) || x.LicenseStatus == ComboLicenseStatus.Text)
&& (IsNullOrEmpty(ComboSelectTheterrace.Text) || x.Theterrace == ComboSelectTheterrace.Text)
&& (x.rebuilt == _Grouprebuilt ||IsNullOrEmpty(_Grouprebuilt))
/////////////////////////////////
&& (x.ColonialProperty == _ColonialProperty ||
IsNullOrEmpty(_ColonialProperty))
/////////////////////////////////
&& (x.MelkFor.Size >= Sizeaz ||
IsNullOrEmpty(textSizeaz.Text)) &&
(x.MelkFor.Size <= Sizeta ||
IsNullOrEmpty(textSizeta.Text))
&& (x.MelkFor.YearBuilt >= YearBuiltAZ ||
IsNullOrEmpty(textYearBuiltAZ.Text)) &&
(x.MelkFor.YearBuilt <= YearBuiltTA ||
IsNullOrEmpty(textYearBuiltTA.Text))
&& (x.NumberBedrooms >= Sleepaz ||
IsNullOrEmpty(textSleepaz.Text)) &&
(x.NumberBedrooms <= Sleepta ||
IsNullOrEmpty(textSleepta.Text))
&& (x.TotalNumberUnitsComplex >= TotalNumberUnitsComplexAZ ||
IsNullOrEmpty(textUnitAZ.Text)) &&
(x.TotalNumberUnitsComplex <= TotalNumberUnitsComplexTa ||
IsNullOrEmpty(textUnitTa.Text))
&& (x.NumberFloors >= FloorsAZ ||
IsNullOrEmpty(textFloorsAZ.Text)) &&
(x.NumberFloors <= FloorsTA ||
IsNullOrEmpty(textFloorsTA.Text))
&& (x.FloorAP >= sspinFloorAZ ||
IsNullOrEmpty(spinFloorAZ.Text)) &&
(x.FloorAP <= sspinFloorTA ||
IsNullOrEmpty(spinFloorTA.Text))
&& (x.Singlee == _tak || IsNullOrEmpty(_tak))
&& (x.ExclusiveCourtyard == _courtyard.Trim() ||
IsNullOrEmpty(_courtyard.Trim()))
)
.Select()
وقتی شرط های مثل این را حذف میکنم
&& (x.MelkFor.SalesPrices >= SalesPriceaz || IsNullOrEmpty(textSalesPriceaz.Text)) && (x.MelkFor.SalesPrices <= SalesPriceta || IsNullOrEmpty(textSalesPriceta.Text))
که از کوچیکتر و بزکتر استفاده میشه نتیجه کوئری اشتباه میشه
چگار کنم که بتونم تمام شرایط اعمال کنم
میشه کوئری روی کوری بزنیم یعنی تو در تو؟
سلام
پون شما از || استفاده کردید
بله جدا کنید و شرطها رو جدا بزنید
یعنی اول یک کوری بزنم با یک سری شرط ها بعد روی خروجی اون دوبار و دست اخر شرطهای که || دراه را استفاده کنم
بله
فقط .Tolist نزنید تا اجرا نشه و در آخر بزنید