Created
May 11, 2018 21:53
-
-
Save hasokeric/97af7c93c9e3aad93ef3e3a325a40761 to your computer and use it in GitHub Desktop.
BPM Double to String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
//Gist File: README-NOTES-BPMDoubleToString | |
// 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}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment