c# - Implicitly typed local variables must be initialized -
here code :- how initialize data
?
var data; if (mode == "view") { data = (from in ctx.tblemployee a.companyid == companyid join b in ctx.tblto_shiftschedule on a.id equals b.employeeid b.companyid == companyid select new { a, b, c, d }).tolist(); } else { data = (from in ctx.tblemployee a.companyid == companyid select new { a, b, c, d }).tolist(); }
you can't initialize anonymous type, so:
var data = mode == "view" ? (from in ctx.tblemployee a.companyid == companyid join b in ctx.tblto_shiftschedule on a.id equals b.employeeid b.companyid == companyid select new { a, b, c, d }).tolist() : (from in ctx.tblemployee a.companyid == companyid select new { a, b, c, d }).tolist();
Comments
Post a Comment