Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is UserQuery in Linqpad? [duplicate]

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

like image 856
NewbieFreak Avatar asked Dec 06 '12 11:12

NewbieFreak


2 Answers

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.

like image 56
Daniel Hilgarth Avatar answered Sep 22 '22 06:09

Daniel Hilgarth


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.

like image 28
Joe Albahari Avatar answered Sep 22 '22 06:09

Joe Albahari