>>var lastLocSuffix = _salespointAdapter.GetAll().Select(sp => new { LocSuffix = sp.LocSuffix }).OrderByDescending(sp => sp.LocSuffix).FirstOrDefault(); >> Int16 newSuffix = 1; >> if (lastLocSuffix != null) >> newSuffix = Convert.ToInt16(lastLocSuffix) + newSuffix; // Doesn't like this line >> >> salespoint.LocSuffix = newSuffix; >>>>
var lastLocSuffix = _salespointAdapter.GetAll().Select(sp => new { LocSuffix = sp.LocSuffix }).Max(); Int16 newSuffix = 1; if (lastLocSuffix != null) newSuffix = Convert.ToInt16(lastLocSuffix); salespoint.LocSuffix = newSuffix;The LocSuffix is defined
public short LocSuffix { get; set; } // loc_suffix. 3 digit prefix appended to each sale, pass, invoice, etc... issued by this station.So, I just need to increment it by one after getting the max from the database. If I try to add + newSuffix in the newSuffix assignment line, I get the error back.