LinqPad,使用多个datacontexts [英] LinqPad, using multiple datacontexts

查看:168
本文介绍了LinqPad,使用多个datacontexts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常在不同数据库中的表的数据进行比较。这些数据库没有相同的模式。在TSQL,我可以用DB>用户>表结构(DB1.dbo.Stores,DB2.dbo.OtherPlaces)引用它们拉的数据进行比较。我喜欢LinqPad的相当多的想法,但我似乎无法方便地同一套statments内拉来自两个不同的数据的上下文数据。



我见过的人建议简单地改变连接字符串从其他来源到当前架构提取数据,但是,正如我所说,这是不行的。难道我只是跳过FAQ页面?这似乎是一个相当常规程序不可用我。



在易的世界里,我喜欢能够简单地引用类型的DataContext的LinqPad创建。然后,我可以简单的:



DB1DataContext DB1 =新DB1DataContext();



DB2DataContext DB2 =新DB2DataContext()



和工作从那里。



如果任何人有一个建议,我肯定很感激。谢谢


解决方案

更新:这是现在可以做跨数据库的SQL Server查询在LINQPad(从LINQPad V4.31,与LINQPad高级许可证)。要使用此功能,按住Ctrl键的同时拖动从架构资源管理器数据库查询窗口。



它也可以查询的链接服务器(你已经通过调用链接 sp_add_linkedserver )。要做到这一点:




  1. 添加一个新的LINQ to SQL连接

  2. 选择指定新的或现有的数据库并选择您要查询的主数据库。

  3. 点击包含其他数据库复选框,并选择链接的服务器(S)从列表中。


  4. I am often comparing data in tables in different databases. These databases do NOT have the same schema. In TSQL, I can can reference them with the DB>user>table structure (DB1.dbo.Stores, DB2.dbo.OtherPlaces) to pull the data for comparison. I like the idea of LinqPad quite a bit, but I just can't seem to easily pull data from two different data contexts within the same set of statments.

    I've seen people suggest simply changing the connection string to pull the data from the other source into the current schema but, as I mentioned, this will not do. Did I just skip a page in the FAQ? This seems a fairly routine procedure to be unavailable to me.

    In the "easy" world, I'd love to be able to simply reference the typed datacontext that LinqPad creates. Then I could simply:

    DB1DataContext db1 = new DB1DataContext();

    DB2DataContext db2 = new DB2DataContext();

    And work from there.

    If anyone has a suggestion, I'd surely appreciated it. Thanks.

    解决方案

    Update: it's now possible to do cross-database SQL Server queries in LINQPad (from LINQPad v4.31, with a LINQPad Premium license). To use this feature, hold down the Control key while dragging databases from the Schema Explorer to the query window.

    It's also possible to query linked servers (that you've linked by calling sp_add_linkedserver). To do this:

    1. Add a new LINQ to SQL connection.
    2. Choose Specify New or Existing Database and choose the primary database you want to query.
    3. Click the Include Additional Databases checkbox and pick the linked server(s) from the list.

    这篇关于LinqPad,使用多个datacontexts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆