Id Employee_Id Sector_Id Datei want to delete all records base on sector_Id and given date??
1 xxx kkk 2015-12-15
1 sss ddd 2015-12-15
1 fff nnn 2015-12-15
i have search google but there is no method to delete all record at once
i am using this code
var deleteRecord1 = _service.GetAllDutyPointStatus().Where(x => x.Date == dt && x.Sector_Id == sectorId).Count();
if (deleteRecord1 != null)
{ _service.DeleteDutyPointStatus(deleteRecord1); }
else { MsgLitteral.ShowNotificationInline("No Record Found!.", true); }
when cleint click on delete button all record base on date and sector,all record delete

VulpesPosted Feb 17, 2015, 10:15 AM
var deleteRecord1 = _service.GetAllDutyPointStatus().Where(x => x.Date == dt && x.Sector_Id == sectorId).Count();
All this does is count the records to be deleted - it doesn't return references to the records themselves.
Also it's never going to be null as it's an int.
If the _service.DeleteDutyPointStatus method takes a 'scalar' variable as a parameter (i.e. not an array or other collection but a single record reference), you could try instead:
var deleteRecord1 = _service.GetAllDutyPointStatus().Where(x => x.Date == dt && x.Sector_Id == sectorId);
if (deleteRecord1.Count() > 0)
{
foreach(var record in deleteRecord1)
{
_service.DeleteDutyPointStatus(record);
}
}
else
{
MsgLitteral.ShowNotificationInline("No Record Found!.", true);
}
Sajid HussainPosted Feb 18, 2015, 1:24 AM
Guest UserPosted Feb 17, 2015, 9:55 AM