• 1397/08/27

استفاده از MyGenericRepository :

سلام اساد من از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))

که از کوچیکتر و بزکتر استفاده  میشه نتیجه کوئری اشتباه میشه 

چگار کنم که بتونم تمام شرایط اعمال کنم 

میشه کوئری روی کوری بزنیم یعنی تو در تو؟

  • 1397/08/27
  • ساعت 14:10

سلام 

پون شما از || استفاده کردید 

بله جدا کنید و شرطها رو جدا بزنید 


  • 1397/08/27
  • ساعت 14:13

یعنی اول  یک کوری بزنم  با یک سری شرط ها بعد روی خروجی اون دوبار و دست اخر شرطهای که || دراه را استفاده کنم


  • 1397/08/27
  • ساعت 14:28

بله 

فقط .Tolist نزنید تا اجرا نشه و در آخر بزنید 


logo-enamadlogo-samandehi