select a.stakebuyinid , a.StakeBuyInValue from StakeBuyInByStakeCategories AS b
left join StakeBuyIns AS a on b.stakebuyinid = a.stakebuyinid
where b.GametypeId = 1 and b.StakeCategoryID = 3 and a.Currencyid = 1
以上是我想用 LINQ 编写的简单 SQL 查询
我正在使用以下 LINQ 查询,但引发错误:-“转换为值类型 'Int32' 失败,因为具体化值为空。结果类型的泛型参数或查询必须使用可为空的类型。”
var query = (from v in db.StakeBuyInByStakeCategories.Where(x => x.GameTypeId == gametypeid && x.StakeCategoryId == stakecategoryid)
join u in db.StakeBuyIns.Where(y => y.CurrencyId == currencyid)
on v.StakeBuyInId equals u.StakeBuyInId into Temp
from vus in Temp.DefaultIfEmpty()
select new {
vus.StakeBuyInId,
vus.StakeBuyInValue )