-1
我只是嘗試使用與EFF與Mysql以下Linq查詢導出[]數組裏面:如何爲int轉換爲字符串LINQ查詢
DM_ItemGroup[] array =
(from item_grp in DbContext.hexa_item_group
join item_btn in DbContext.hexa_button
on item_grp.GroupID equals item_btn.ButtonID
where item_btn.ButtonType.Equals("G", StringComparison.Ordinal)
select new DM_ItemGroup
{
GroupID = SqlFunctions.StringConvert((decimal)item_grp.GroupID),
GroupName = item_grp.GroupName,
ButtonID = item_btn.ButtonID,
Default_TaxId = item_grp.Default_TaxId,
Out_Of_Sales = item_grp.Out_Of_Sales,
Sales_Seq = item_grp.Sales_Seq,
DataModel_Button = new DM_Button(),
}).ToArray<DM_ItemGroup>();
我最初嘗試.ToString()
,但它給了一個例外。試圖SqlFunctions.StringConvert
後,我收到以下錯誤: -
The specified method 'System.String StringConvert(System.Nullable`1[System.Decimal])'
on the type 'System.Data.Objects.SqlClient.SqlFunctions'
cannot be translated into a LINQ to Entities store expression.
如何將羣ID(這是詮釋我的表)爲String(這是由我的DataModel需要)轉換?
的可能的複製[LINQ到實體StringConvert(雙)」不能轉換爲INT轉換爲字符串(https://開頭計算器.com/questions/5771299/linq-to-entities-stringconvertdouble-can-be-translate-to-convert-int-to-s) – CodeCaster
@CodeCaster:我已經看過所有這些建議,並且實現了相同的功能,但沒有爲我工作。因此,請給我一個解決方案。 –
哦,是的,我錯過了「MySQL」的一部分。你發現SqlFunctions是特定於SQL Server的,對嗎? – CodeCaster