我在.net中,此代碼,我得到這個錯誤:C#無法隱式轉換類型「System.Linq.IQueryable <<匿名類型:
C# Cannot implicitly convert type System.Linq.IQueryable<<anonymous type:..
有人可以幫我指點迷津?
IQueryable<Reservations> queryRes;
queryRes = (from p in ctx.Reservations
join a in ctx.Employees on p.Id_employee equals a.Id
join c in ctx.Clients on p.Id_client equals c.Id
orderby p.Id
select new
{
p.Date,
p.Hour,
c.Name,
c.Surname,
p.Email,
p.Phone,
p.Service,
name1=a.Nume,
surname1=a.Prenume
});
reservationsView.Source = queryRes.ToList();
CollectionViewSource reservationsView; reservationsView =((CollectionViewSource)(this.FindResource(「reservationsViewSource」))); – greeny
您正投射到匿名類型中,而不是投射到「預訂」中。 – Crowcoder