Hi
I am getting error on Resulr.count
C#
var Result = from t in context.View_MachineShiftDetails
where t.Department == ddlDepartment.SelectedValue
&& t.MachineShiftID == Convert.ToInt32(hdfMachineShiftId.Value)
orderby t.MachineName
select new { t.MachineShiftID, t.Department, t.LocationID, t.Location, t.MachineID, t.MachineName,t.NumberOfShift };
if (Result.Count > 0)Thanks

Amit MohantyRank #112 · 20K reputationPosted Nov 30, 2022, 3:36 AM EST
Use Result.Count().
Jignesh KumarRank #91 · 22.9K reputationPosted Nov 30, 2022, 3:21 AM EST
Hello,
use this one,
if (Result.Any()) { // Your statement } OR if (Result != null && Result.Count() > 0) { // Your statement }Rajesh GamiRank #30 · 41.5K reputationPosted Nov 30, 2022, 2:45 AM EST
Hello Ramco
Try the below query
if (Result != null && Result.Count() > 0) { // Your statement }Sometimes what happens like you haven't gotten any record in the list but you check directly to count.