Home

Creating my own DataContext

Hello!
I brought a piece of code from my application to LINQPad. In this piece I'm creating my own DataContext in order to assign LoadOptions object to it. But then I'm referring to DB tables in query through this object and obviously get errors because my entity classes file has left in the program and I can't attach it to LINQPad.
How to deal with DataContext in LINQPad?

Comments

  • Use 'this':

    this.LoadOptions = ...

    or just:

    LoadOptions = ...

    To make copying and pasting between LINQPad and Visual Studio easier, you can assign 'this' to a local variable:
    var db = this;
    db.LoadOptions = ...
    var myQuery = db.Where(...).Select(...);
    myQuery.Dump();
Sign In or Register to comment.