Cast Nullable Ints inside your Select in Linq
Needed to return a single value and cast it as an int instead of an int?
public int getFranchiseePOS(string AccountCode)
{
var qry = (from s in MyEntities.Franchisees
join p in MyEntities.POS on s.POSID equals p.POSID into XX
from subgroup in XX.DefaultIfEmpty()
where s.AccountCode == AccountCode
select s.POSID==null ? 0 :(int) s.POSID
).FirstOrDefault();
return qry;
}
public int getFranchiseePOS(string AccountCode)
{
var qry = (from s in MyEntities.Franchisees
join p in MyEntities.POS on s.POSID equals p.POSID into XX
from subgroup in XX.DefaultIfEmpty()
where s.AccountCode == AccountCode
select s.POSID==null ? 0 :(int) s.POSID
).FirstOrDefault();
return qry;
}
Comments