var result type problem

var result type problem

Postby billh » Thu 27 Aug 2009 13:01

Hello!!

I have the following code...

int convertedId = Int32.Parse(id);

var res = from p in rms_cntxt.Rms
where p.RmsNbr == convertedId
select p;

return View("Edit", res);

The consumer of this return 'res' results in this error

The model item passed into the dictionary is of type 'Devart.Data.Linq.DataQuery`1[RMS1.Rms]' but this dictionary requires a model item of type 'RMS1.Rms'.

Changing the 'var' to 'Rms' does not fix things - that results in

Cannot implicitly convert type 'System.Linq.IQueryable' to
'RMS1.Rms'. An explicit conversion exists (are you missing a cast?).


So I don't know how to fix this - hoping for suggestions.
Thanks, Bill
billh
 
Posts: 2
Joined: Thu 30 Jul 2009 16:02

Postby billh » Thu 27 Aug 2009 19:58

Changed return View("Edit", res);

To

return View("Edit, res.First());

So now I am wondering if this hack is ok.
I am still confused as to whether 'res' is an object or array of objects, or what.

Thanks,
Bill
billh
 
Posts: 2
Joined: Thu 30 Jul 2009 16:02

Postby Shalex » Tue 01 Sep 2009 12:03

res is a collection, res.First() is its first element. There is no definition for the View class, so we cannot provide you the exact code. Please refer to MSDN to get the description of the LINQ language.
Shalex
Devart Team
 
Posts: 7841
Joined: Thu 14 Aug 2008 12:44


Return to LinqConnect (LINQ to SQL support)