LINQ Configurator Event Expression On Load number formatting issue

I have been successful getting data assigned to controls with the On Load event expressions.
For Example:
Inputs.Thickness.Value = Db.JobAsmbl.Where(r => r.Company==“DTSF” && r.JobNum == Context.JobNumber && r.AssemblySeq == Context.AssemblySeq).Select( r =>r.Number04.ToString()).DefaultIfEmpty(“Not Found”).FirstOrDefault();

The problem I am having is that I have been unable to format out the trailing zeros in this ToString statement r.Number04.ToString() yielding on my form.
image

I have tried
r.Number04.ToString(“G29”)
r.Number04.ToString(“0.####”)
r.Number04.ToString(“G”)
r.Number04.ToString(“0.0000”)

All yield this Application Error
image

I don’t see in my web searches any formating available in LINQ for decimal numbers that I could use before the ToString().

Any suggestions out there?

Thanks
Mike

I think since you made it part of the select statement, its trying to convert it to an SQL statement or some such. Try assigning it to a temporary variable and them performing the ToString operation on the temporary variable instead.

1 Like

That did it after I fixed the DefaultIfEmpty(“Not Found”) to DefaultIfEmpty(0).

Thanks Evan!

1 Like