How can I use LinqPad's generated context in Visual Studio

折月煮酒 提交于 2019-11-30 22:05:53

First, extract the typed data context in LINQPad as follows:

string dcPath = GetType().BaseType.Assembly.Location;
string targetFolder = @"c:\temp";
File.Copy (dcPath, Path.Combine (targetFolder, Path.GetFileName (dcPath)));

Then in Visual Studio, reference the typed data context DLL, along with the following DLLs from the driver folder:

  • IQDriver.dll
  • IQToolkit.dll
  • IQToolkit.Data.dll
  • IQToolkit.Data.(provider).dll

plus the DevArt driver.

Then, you can instantiate the typed data context as follows (this illustrates how to do it for SQLite):

var dc = new LINQPad.User.TypedDataContext (IQToolkit.Data.DbEntityProvider.From
   ("IQToolkit.Data.Sqlite", @"Data Source=D:\SQLite.NET\nutshell.db",
    "LINQPad.User.TypedDataContext"));

var customerCount = dc.Customers.Count();

This should get you started. Bear in mind the caveats, as stated in the answer to which you linked!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!