3 回答

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

TA貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個(gè)贊
這個(gè)怎么樣。在此示例中,db中的VDN字段和Skill字段都是整數(shù)。我正在尋找來(lái)自兩個(gè)領(lǐng)域的比賽,所以我有2個(gè)比較。
包括以下內(nèi)容:
using System.Data.Objects.SqlClient; // needed to convert numbers to strings for linq
比較數(shù)字時(shí),請(qǐng)執(zhí)行以下操作:
// 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
工夫。
添加回答
舉報(bào)