Example of using SQLFunctions to convert a double/int or w/e to a string in LINQ / BPM.
// Epicor Does something similar:
where XFileAttch_Row.Key1 == SqlFunctions.StringConvert((double)ttInvcHeadRow.InvoiceNum).Trim()
// Canonical and Database Functions
Fortunately instead of using unsupported syntax you can enrich your LINQ to Entities queries with custom functions that work on strings, dates, aggregations and so on
The Entity Framework in .NET 4 provides two classes: SqlFunctions and EntityFunctions you can invoke these inside of queries with the guarantee that they will be converted properly into the command tree so the query will
not fail during translation from conceptual to storage model.
where c.Country == "USA" && EntityFunctions.DiffDays(o.OrderDate, DateTime.Now) <= 7
select new {o.OrderID, o.OrderDate};
var partTranRow =
(from ud07 in Db.UD07.With(LockHint.UpdLock)
join pt in Db.PartTran.With(LockHint.NoLock)
on new { ud07.Company, TranNum = ud07.Key1, TranType = "MFG-STK" } equals new { pt.Company, TranNum = System.Data.Objects.SqlClient.SqlFunctions.StringConvert((double)pt.TranNum).Trim(), TranType = pt.TranType }
where ud07.Company == callContextClient.CurrentCompany && ud07.Key3 == sSerialNum
select new { ud07, pt.TranNum, pt.TranType, PartTranCheckBox05 = pt.CheckBox05, pt.LotNum }
).FirstOrDefault();