3 回答

TA貢獻1803條經驗 獲得超3個贊
那不能轉換成SQL。我猜,從理論上講,它可以,但是沒有實現。
得到結果后,只需執行投影即可:
var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing
select m.PricingSecurityID).AsEnumerable()
.Select(x => new SelectListItem{ Text = x.ToString(), Value = x.ToString() });

TA貢獻1943條經驗 獲得超7個贊
這個怎么樣。在此示例中,db中的VDN字段和Skill字段都是整數。我正在尋找來自兩個領域的比賽,所以我有2個比較。
包括以下內容:
using System.Data.Objects.SqlClient; // needed to convert numbers to strings for linq
比較數字時,請執行以下操作:
// Search Code
if (!String.IsNullOrEmpty(searchString))
{
depts = depts.Where(d => SqlFunctions.StringConvert((double)d.VDN).Contains(searchString.ToUpper())
|| SqlFunctions.StringConvert((double)d.Skill).Contains(searchString.ToUpper()));
}
// End Search Code
工夫。
添加回答
舉報