Linq. Anonymous type error when joining to multiple tables

Melchy

New Member
Im trying to return an IQueryable based on my model.But I need to join to the same lookup table twice. Then return the query variable to the gridview. \[code\]public IQueryable<Benchmark> GetBenchMarks([QueryString("hydrant")] string hydrant,[QueryString("revdate")] string revdate, [QueryString("street")] string street,[QueryString("quadrant")] string quadrant, [QueryString("desc")] string desc) { IQueryable<Benchmark> query = from p in _db.Benchmarks join s in _db.Streets on p.Street1Number equals s.Id join s2 in _db.Streets on p.Street2Number equals s2.Id select new { Street1Name = s.StreetName, p.OrderNumber, p.HydrantNumber, Street2Name = s2.StreetName, p.RevisionDate, p.Quadrant, p.Description, p.Street1Number };}\[/code\]So there is a red squiggle line on the 2nd join to s2. And the following error.\[quote\] \[code\]Error 5 Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'System.Linq.IQueryable<Benchmarks.Model.Benchmark>'. An explicit conversion exists (are you missing a cast?) C:\Projects\Benchmarks\Benchmarks\Benchmarks_Home.aspx.cs 63 25 Benchmarks\[/code\]\[/quote\]
 
Back
Top