对于我的生活中,我想不通,我怎么得到的错误Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'bool?'
如果我双击它带我到HomeController的错误,并强调该行内选择语句statsModel.Donations = (from q in db.Shows where (q.Id == 1) select new { q.Donations });
。
Show.cs
namespace WebApplication1.Models
{
using System;
using System.Collections.Generic;
public partial class Show
{
public int Id { get; set; }
public Nullable<bool> Donations { get; set; }
}
}
StatsisticsModel.cs
namespace WebApplication1.Models
{
using System;
public class StatisticsModels
{
public int UserCount { get; set; }
public decimal? TotalAmount { get; set; }
public Nullable<bool> Donations { get; set; }
}
}
HomeController的
[ChildActionOnly]
public ActionResult Statistics()
{
var statsModel = new StatisticsModels();
statsModel.UserCount = (from m in db.AspNetUsers where (m.UserName != "someone") && (m.EmailConfirmed == true) select new { m.UserName }).Count();
statsModel.TotalAmount = db.Donations.Sum(o => o.Amount);
statsModel.Donations = (from q in db.Shows where (q.Id == 1) select new { q.Donations });
return View(statsModel);
}
任何人都可以请帮助,我要返回的是显示表内的捐赠和人民领域是否是真的还是假的特定记录。
任何帮助我非常感谢:-)