为什么linq contains在与空字符串和非空字符串组合时总是返回false值?

wlzqhblo  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(132)

详细内容:
1.在下面的代码中,_reportData.DistrictIDreportData.BeneficieryID的值是""。但过滤条件不起作用。我的要求是从表中获取匹配的值。
1.下面的代码没有过滤数据。
下面是检索筛选数据的代码

public async Task<IEnumerable<BeneficieryMasterExcelUpload>> GetBeneficieryReports(ReportsDataSearch _reportData)
    {
       

        IEnumerable<BeneficieryMasterExcelUpload> beneficieryList = _appDBContext.BeneficieryMasterExcelUpload;
        try
        {

            var beneficieryList = (from b in _appDBContext.BeneficieryMasterExcelUpload
                                   where b.Financial_Year.Contains(_reportData.FinancialYear)
                                   || b.District.Contains(_reportData.DistrictID) ||
                                   b.Name.Contains(_reportData.BeneficieryID) ||
                                   b.District.Contains(_reportData.DistrictID) ||
                                   b.Taluk.Contains(_reportData.TalukID) ||
                                          b.Village.StartsWith(_reportData.VillageID) ||
                                           b.SchemeName.Contains(_reportData.SchemeMasterID)


                                   select new BeneficieryMasterExcelUpload()
                                   {
                                       BeneficieryID = b.BeneficieryID,
                                       Name = b.Name,
                                       SchemeName = b.SchemeName,
                                       BusinessName = b.BusinessName,
                                       District = b.District,
                                       Taluk = b.Taluk,
                                       Village = b.Village,
                                       Constitunency_num = b.Constitunency_num,
                                       BankName = b.BankName,
                                       Financial_Year = b.Financial_Year,
                                       Religion = b.Religion,

                                   }).ToList();
            return beneficieryList;
        }
        catch (Exception ex)
        {
            return null;
        }

字符串

fzwojiic

fzwojiic1#

您是否试图使用BeneficieryID过滤Beneficiery
我注意到其中一行写着b.Name.Contains(_reportData.BeneficieryID)。相反,您是否试图引用b.Beneficiery.Contains(_reportData.BeneficieryID)

相关问题