var result type problem

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
billh
Posts: 2
Joined: Thu 30 Jul 2009 16:02

var result type problem

Post by 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

Post by 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

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Post by 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.

Post Reply