是否有.NET相当于Rails的控制台? [英] Is there a .NET equivalent to Rails Console?

查看:106
本文介绍了是否有.NET相当于Rails的控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails的控制台是模型的直接完整性检查非常有用。是否有一个ASP.NET MVC等同?

Rails Console is so useful for direct sanity-checking of your model. Is there an ASP.NET MVC equivalent?

是否有可能使用LinqPAD模仿Rails的控制台的行为吗?

Is it possible to mimic Rails Console behaviour using LinqPAD?

推荐答案

真棒 - 我发现LinqPAD 4.38.03(最新测试版)完美的作品还有一个Rails控制台替代

awesome - I discovered LinqPAD 4.38.03 (latest beta version) works perfectly well as a Rails Console substitute!

我的ASP.NET MVC3项目是基于实体框架4.2(第一个数据库使用的方法),这与Linqpad很好地集成。我能够引用我的组件作为连接和查询模式,控制器,仓库等交互方式,就像在Rails的控制台!

My ASP.NET MVC3 project is based on Entity Framework 4.2 (using the "database first" approach) which Linqpad integrates nicely with. I am able to reference my assembly as a connection and query the model, controller, repositories etc. interactively, just like in Rails Console!

这是我的步骤


  1. 在连接管理器(左侧),点击添加连接

  2. 点击标有使用类型化的数据上下文从自己组装的无线电

  3. 单击实体框架的DbContext POCO(4.1 / 4.2),然后点下一步

  4. 使用浏览找到路径的自定义组件(在您的项目)

  5. 单击选择,从程序集中选择的DbContext类

  6. 单击选择以找到您的项目配置文件中的路径应用程序配置文件

  7. 键入一个可选的连接名称,点击下一步

最后,在查询窗口中选择新的组件连接的数据库,这就是它!现在,您可以与您的装配工作,交互

Finally, in your query window select your new assembly connection as the "Database" and that's it! You can now work with your assembly interactively.

例如,以检查和测试控制器:(第一,在查询属性,添加到 System.Web.Mvc 的引用)

For example, to inspect and test a controller: (first, in Query Properties, add a reference to System.Web.Mvc)

var controller = MyProject.Controllers.CustomerController();
controller.Index().Dump();

要后的一些数据

var customer = new Customer() {name = "Brian"};
controller.Create(customer);

要看到你的新的客户数据库中的

to see your new Customer in the database

Customers.Dump();

或者如果你有一个仓库

or if you have a repository

var repo = new Repository();
repo.GetCustomers().Dump();

这篇关于是否有.NET相当于Rails的控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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