想要从多个表到一个服务层数据,因为我有数据库逻辑为服务层写了我的项目我想要从多个表以服务纳税人数据到我的项目
“KeysPlus.Service .Models.QuoteModel'到'System.Collections.Generic.IEnumerable'。 存在明确的转换(您是否缺少演员?)
任何帮助都非常感谢!
public static IEnumerable<QuoteModel> GetJobQuotes(Login login, QuoteModel model)
{
using (var db = new KeysEntities())
{
var quotes = db.JobQuote.Where(x=> x.ProviderId == login.Id);
model = (from q in db.JobQuote
join j in db.Job on q.JobId equals j.Id
join p in db.Property on j.PropertyId equals p.Id
join a in db.Address on p.AddressId equals a.AddressId
select new QuoteModel
{
JobDescription=j.JobDescription,
QuoteAmount=q.Amount,
PropertyAddress= a.City
}).ToList();
return model;
}
}
不要改变你的问题,是无效有答案得到了。 –
@StephenMuecke,对不起。我刚刚更新,因为一些其他错误将基于David – Rajesh
提出的更改,然后附加您尝试的新代码和新的错误消息。但是你已经说过你想返回一个列表,所以使用'.First()'没有任何意义 - 返回一个单一的对象。 –