6

Possible Duplicate:
LINQPad error: ‘UserQuery’: cannot derive from sealed type ‘My.Entity.Framework.CustomDataContext’

i am running this query in LINQPad 4 with C# Expression as language

from t in typeof(UserQuery).GetProperties()
where t.Name == "tablename"
from c in t.GetValue(this,null).GetType().GetGenericArguments()[0].GetFields()
select c.Name

but when i use this query in C# web application it gives error no reference of UserQuery

var result = from t in typeof(UserQuery).GetProperties()
             where t.Name == "tablename"
             from c in t.GetValue(this,null).GetType().GetGenericArguments()[0].GetFields()
             select c.Name

and vs 2012 intellisense didnt picked any reference of it. please tell me which library reference is needed to be added for execution of above query or which class object is needed to be created for referencing ??

currently i m using EF 5.0 and DbContext object which is generated when creating EF data model by Database First Approach

i prefer answer which related to DbContext

Community
  • 1
  • 1
NewbieFreak
  • 325
  • 1
  • 4
  • 13

2 Answers2

4

UserQuery is the class LINQPad uses as a container for the code you enter into its textfield. As such, it is only available to code you run in LINQPad.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
1

It sounds like you're trying to query the properties of a typed data context.

To get this working in Visual Studio, replace UserQuery with the name of your typed DataContext.

Joe Albahari
  • 30,118
  • 7
  • 80
  • 91