- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
几天来我一直在考虑这个想法,但我找不到任何明确的证据表明这个想法行得通或行不通。
我想要做的是使用 LinqPad 查询创建一个 EF 4.1 代码优先数据库,该数据库具有 SQL Server CE 支持,位于与查询相同的目录中(可能与查询命名相同)。这样做的原因是为了快速建立一个数据库来存储查询结果以供进一步处理。
想法是将类定义存储在查询中,即(这些将适用于最新的 beta
public class User
{
public long Id { get; set; }
public string Name{ get; set; }
}
public class MyDBContext : DbContext
{
// note the overloaded constructor
// just pass in the LinqPad UserQuery connection
public MyDBContext(DbConnection connection) : base(connection, true)
{}
public DbSet<User> Users { get; set; }
}
然后在查询中:
#define NONEST
public Main()
{
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyDBContext>());
// pass in the current database connection to point EF to the right database
var context = new MyDBContext(this.Connection);
context.Users.Add(new User(){Name = "Test User"});
context.SaveChanges();
context.Users.Dump("Contents of Users table");
}
我在 LinqPad 中引用了 EntityFramework 4.2.0.0,但在我的查询中,我看不到 System.Data.Entity
命名空间。这是否表明存在其他问题?
我不确定我是否提供了足够的上下文或信息,所以如果您需要澄清,请告诉我。这可以做到吗? LinqPad 还不支持这个吗?
更新:
似乎 EF 无法映射嵌套类,而这正是 LinqPad 查询定义的类。我在这方面不是很有经验,但似乎我已经走到了死胡同。除非 Joe Albahari 能够以某种方式实现非嵌套用户类,否则这看起来行不通。有人有想法吗?
最终更新:
使用 latest beta ,这完全有效。它需要事先创建 .sdf
数据库文件,但所有其他操作都应该有效。很酷。谢谢 Joe Albahari!
最佳答案
关于entity-framework - LinqPad + EF 4.1 + SQL Server CE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8730225/
根据 LINQPad 网站,有几种不同的构建 原版版本(homepage 上的“立即下载”) X64 版本 AnyCPU build http://www.linqpad.net/Beta.aspx
总NOOB问题。我已经使用新的linqpad大约20分钟了。伟大的! 但是现在我想在数据库中删除一行。我正在使用EF5.0连接。我似乎无法在帮助文件或网上找到任何内容。我唯一能找到的是DeleteOn
在 LINQPad 的左下角,有一个显示查询的区域。一个选项卡是我的查询,另一个选项卡是 sample 。我找不到像在“我的查询”中那样添加多个文件夹的方法,就像在“示例”选项卡中一样。我尝试右键单击
在 Linqpad 中重新运行查询之间会保存什么状态?我假设没有,所以如果你运行一个脚本两次,它两次都会有相同的结果。 但是,在同一个 Linqpad 选项卡中运行下面的 C# 程序两次。你会发现第一
Linqpad 是唯一一个类似脚本的环境,我可以在其中使用我的大型代码库。它是唯一适合我的环境的原因是其他解决方案(ironpython 等)总是无法从 app.config 正确加载配置,但 lin
我的团队有很多我们通过 git 存储库共享的 linqpad 脚本。我们使用对我们自己的代码库的引用,其中每个团队成员的本地路径可能不同。因此,如果我们想要运行这样的脚本,我们需要首先编辑它的引用以指
在 LinqPad 中,我可以使用类似的东西 Console.ReadKey(); 或者 Util.ReadLine(); 但是,如何以可以实际输入输入的方式运行这些程序? UI 没有控制台窗口! 最
当我在 Linqpad 中运行查询时,我想在针对生产数据库运行查询时做一些额外的检查,是否有一种方法可以通过编程方式检测当前 linqpad 脚本的连接字符串是否处于事件状态标记为生产? 最佳答案 是
LINQPad 中显示的结果是有限的。如果对象嵌套很深,则会显示一条红线。 我想增加一个限制,这样我就可以看到更多的嵌套对象。 你知道怎么做吗? (我在选项中没有找到。) Background not
使用 LINQPad,使用扩展方法 Dump()、Console.WriteLine 或 Debug.Writeline,这些值将出现在结果窗口中。 有没有办法在 linqpad 脚本运行期间清除此结
我有一个 LINQPad 脚本文件 *.linq 并且有数据库连接的密码。如何提取密码? (看起来像是Base64编码的二进制数据。) 最佳答案 LINQPad 使用 DPAPI 加密密码。因此,只有
如何在 Linqpad 的文本编辑器中启用自动换行? 最佳答案 现在 LINQPad 中没有自动换行选项。您可以注册一个请求 here . 截至 Linqpad Beta v4.48 ,现在支持自动换
有没有办法,当我在 LINQPad 中打开查询时,它会执行它并将我置于仅结果 View 中?其预期用例是在 LINQPad 中编写小型应用程序。我不想每次都按 F5 和 Ctrl+Shift+R。 这
有没有办法在LINQPad中捕获结果面板的内容;也就是说,以编程方式捕获它,例如将其保存到文件中? 最佳答案 查看 LINQPad 的扩展方法。这是一个很好的堆栈溢出问题: LINQPad [exte
我正在引用 NuGet 包 ABCpdf ,它提供了一个托管的 DLL abcpdf.dll以及四对原生 DLL,在 x86 和 x64 版本中: packages\ABCpdf\11.2.2\bui
LinqPad 中的所有 Linq 查询(来自 SQL 的查询数据)都是只读的吗?我无法编辑数据,只能读取它。对? 下面的查询生成只读 View ,我没有找到编辑数据的方法。 from u in Us
我正在尝试为 WinForm 调用 ShowDialog(创建表单的实际代码位于 .linq 脚本中)并且一切正常,但对话框未显示在 LINQPad 应用程序的中心。当多个显示器在运行并且我盯着 LI
我观察到,如果我刷新或重新加载 LINQPad 指定的 Plugins 目录中的 dll,我还必须关闭并重新打开当前脚本才能使库更改生效 - 这当然是有道理的。我的问题是是否有一个命令或键专门执行此重
我正在尝试为 WinForm 调用 ShowDialog(创建表单的实际代码位于 .linq 脚本中)并且一切正常,但对话框未显示在 LINQPad 应用程序的中心。当多个显示器在运行并且我盯着 LI
默认情况下,LINQPAD 中的示例文件位于何处?在 C:\Users\MyUserName\AppData\Roaming\LINQPad\Samples 中,我看到了一些示例,但它不包括默认示例。
我是一名优秀的程序员,十分优秀!