3 Replies - 1478 Views - Last Post: 13 June 2013 - 01:36 PM Rate Topic: -----

#1 AlwaysLearning  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 02-November 12

Cannot convert from IQueryable to ObjectQuery

Posted 13 June 2013 - 08:20 AM

Hi guys,

I am getting the above error (Cannot convert from System.Linq.IQueryable to System.Data.Objects.ObjectQuery)

My auto generated code is...
System.Data.Objects.ObjectQuery<Ascent_ERP.BomDataUpload> bomDataUploadsQuery = bOM_Entities.BomDataUploads;
return bomDataUploadsQuery; 



I was trying to add a where clause. So used..

return bomDataUploadsQuery.Where(c=>c.Manufacturer.Contains("Random Text String"));



Why am I getting this error and what is the solution?

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot convert from IQueryable to ObjectQuery

#2 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 355
  • View blog
  • Posts: 1,519
  • Joined: 08-April 09

Re: Cannot convert from IQueryable to ObjectQuery

Posted 13 June 2013 - 10:24 AM

I'm generalizing here a bit, but most can't convert from to errors you get are because C# is Type safe language and it discourages erroneous or undesirable program behavior caused by a discrepancy between differing data types for the program's constants, variables, and methods (functions), e.g., treating an integer (int) as a floating-point number (float).
Was This Post Helpful? 0
  • +
  • -

#3 Witchking  Icon User is offline

  • D.I.C Head

Reputation: 68
  • View blog
  • Posts: 188
  • Joined: 17-February 13

Re: Cannot convert from IQueryable to ObjectQuery

Posted 13 June 2013 - 10:27 AM

The return type for Queryable.Where<TSource>() is System.Linq.IQueryable<TSource> which doesn't match your method return type.

This post has been edited by Witchking: 13 June 2013 - 10:31 AM

Was This Post Helpful? 0
  • +
  • -

#4 AlwaysLearning  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 02-November 12

Re: Cannot convert from IQueryable to ObjectQuery

Posted 13 June 2013 - 01:36 PM

Hi, thanks for the responses, so how do I add a WHERE clause into an ObjectQuery?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1