here is my code where i need to skip the contractinvoiceperdaysid when if condition fails
and that contractinvoiceperdaysid whose if condition matches shall pass through by join condition using split[,]
List<StaffCIPDApprovedPutModel> lstContractInvoicePerDays = new List<StaffCIPDApprovedPutModel>(); lstContractInvoicePerDays = staffCIPDApprovedViewModel.lstContractInvoicePerDays.ToList(); string contractInvoicePerDayIDs = string.Empty; foreach (var Item in lstContractInvoicePerDays) { //ContractInvoicePerDay contractInvoicePerDay = db.ContractInvoicePerDays.Find(Item.ContractInvoicePerDayID); DateTime _LastModifiedDateTC = Global.GetTimecardLastModifiedDate(Item.ContractInvoicePerDayIDs, (int)InvoiceSourceTypes.PerDay).GetValueOrDefault(); if (Item.LastModifiedDate == _LastModifiedDateTC) { contractInvoicePerDayIDs = string.Join(",", Item.ContractInvoicePerDayIDs); } }