您现在会为数据层选择什么:Linq 还是 Subsonic?

发布于 2024-07-08 07:51:57 字数 170 浏览 8 评论 0原文

我们已准备好在工作中启动一个全新的项目,没有遗留代码。 我们过去确实使用过 Subsonic,我们对此非常满意。 但那是在 Linq 之前。

有人必须面对同样的问题吗(Linq x Subsonic)?

你的决定是什么? 原因是什么?

任何见解表示赞赏。

We are ready to start a brand new project at work, no legacy code. We did use Subsonic in the past and we pretty happy with it. But that was before Linq.

Has anyone had to face this same issue (Linq x Subsonic)?

What was your decision? What were the reasons?

Any insight appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

奶气 2024-07-15 07:51:57

SubSonic

优点:

  • 良好且简单的
  • 脚手架

缺点:

  • 方法签名通常接受可能被滥用的字符串参数(尽管鼓励您使用 DAO 字符串常量)。

请记住:

  • 需要网站项目来进行无代码、无需干预的模型生成(需要 BuildProvider)。

Linq To SQL

优点:

  • IDE 中的语法糖
  • MS 支持
  • 查看要在 IDE 中执行的 SQL
  • 允许在模型中进行不同级别的调整,从自动生成到显式定义再到对象属性。

缺点:

  • 复杂。 您需要学习 DataContext 等新概念才能发挥作用。

请记住:

另请评估 ADO.NET 实体框架此处

SubSonic

Pros:

  • Nice and simple
  • Scaffolding

Cons:

  • Method signatures often accept string parms (though you're encouraged to use DAO string constants) which can be abused.

Keep in mind:

  • Requires Website project for no-code, hands-off model generation (needs the BuildProvider).

Linq To SQL

Pros:

  • Syntactic sugar in the IDE
  • MS supported
  • View the SQL to be executed in the IDE
  • Allows different levels of fiddling in the model, from auto-generation to explicit definitions down to object properties.

Cons:

  • Complex. You need to learn new concepts like the DataContext to be effective.

Keep in mind:

Also evaluate the ADO.NET Entity Framework and here.

爺獨霸怡葒院 2024-07-15 07:51:57

我喜欢 LINQ 的一件事是自动处理连接,我认为 SubSonic 处理得不够优雅。

FROM a in db.Orders
where a.Total > 100
SELECT new {a.Item.Desc, a.Customer.Name};

会自动生成这样的SQLL

select i.DESC, c.NAME 
from  ORDERS o  
inner join ITEMS on o.ItemID = i.ItemID 
inner join CUSTOMERS c on o.CustomerID = c.CUSTOMERID 
where o.TOTAL > 100

The one thing I love about LINQ, which I don't think SubSonic handles as gracefully, is automatically dealing with joins.

FROM a in db.Orders
where a.Total > 100
SELECT new {a.Item.Desc, a.Customer.Name};

will automatically generate SQL like thisL

select i.DESC, c.NAME 
from  ORDERS o  
inner join ITEMS on o.ItemID = i.ItemID 
inner join CUSTOMERS c on o.CustomerID = c.CUSTOMERID 
where o.TOTAL > 100
谜兔 2024-07-15 07:51:57

NHibernate 怎么样? 对于新项目来说真的不可行吗? 不过,来自 Java 的人会发现它很熟悉,您也可以将它与 .NET 2.0 和 Mono 一起使用。

What about NHibernate? Is it really out of the picture for new projects? Still, people coming from Java will find it familiar and you can also use it with .NET 2.0 and Mono.

最丧也最甜 2024-07-15 07:51:57

我选择了 Linq,因为它内置于框架中。 对于那些说 Microsoft 不会支持它的人来说……LinqToSql 将被逐步淘汰。 我相信计划之一是将其吸收到实体框架中。

我现在正在使用实体框架。 它还使用 linq,基本上它与 linqToSql 完全相同,如果您选择使用它,它会具有更大的灵活性和功能。

我倾向于避免使用第三方框架和规范,因为它们最终也会消失。 我相信它们消亡的机会更大,因为它们的生命来自于有多少人对它感兴趣并使用它。 他们的生活也严重依赖于其主要作者/贡献者。

I went with Linq because it's built into the framework. For those saying it will not be supported by Microsoft... it's LinqToSql that is going to be phased out. I believe one of the plans is to absorbe it into the Entity Framework.

I'm now using the Entity Framework. It also uses linq and basically it's exactly like linqToSql with more flexibility and power if you choose to use it.

I tend to avoid 3rd party frameworks and orms because eventually they die out as well. I believe they have more of a chance to die out because their life comes from how many people are interested in it and use it. Their life is also heavily dependent on it's main author/contributor.

情魔剑神 2024-07-15 07:51:57

我的经验主要是使用 SubSonic。 部署非常简单,您将在半小时内完成 DAL。 请记住,这是一把瑞士军刀,因为它是为实用而设计的。 基本上,您会获得每个表生成的类,以及对集合执行延迟加载的能力。 您还可以通过框架执行存储过程,因此如果您有复杂的数据结构,您可以从数据库中获取它们并更新您手工制作的类。

我现在已经在 5 个主要项目中使用了它,我对它的依赖程度印象深刻。

My experience has been primary with SubSonic. It is very straight forward to deploy and you'll have your DAL completed in under a half hour. Bear in mind that this is a Swiss Army knife, as it is designed for utility. Basically you get a class generated per table, as well as the ability to peform lazy loading for collections. You can also execute stored procedures via the framework, so if you have complex data structures you can fetch them from the database and update a class that you hand craft.

I've used it on 5 major projects now, and am impressed with how quickly I became dependent on it.

荒路情人 2024-07-15 07:51:57

我也有同样的情况。 LinQ 更加“视觉化”,你可以在 vstudio 中完成所有操作,甚至 Rob 也承认 subsonic 有一些与之匹配的东西。

IEnumerable、LINQDatasource(带自动分页)和可视化建模说服我选择 Linq 而不是 Subsonic。

I was in the same situation. LinQ is more "Visual", you do everything inside vstudio, and even Rob admits subsonic have a few things to match it.

IEnumerable, LINQDatasource ( with auto paging) and the visual modeling have convinced me to choose Linq over Subsonic.

寄与心 2024-07-15 07:51:57

linq to sql 的最大风险是 Microsoft 会厌倦它并放弃它。 有很多猜测认为这已经发生,并且只会更新实体框架。 Subsonic 不会受到这种情况的影响,更糟糕的情况是你有源代码来进行编辑。

The biggest risk with linq to sql is that Microsoft will grow tired of it and abandon it. There is a lot of speculation that this has already happened and that only the entity framework will be updated. Subsonic does not suffer from this and worse case you have the source code to make your edits.

樱花细雨 2024-07-15 07:51:57

您可能想了解一下 MS 停止开发 LINQ to SQL,正如它似乎正在发生的那样。 SubSonics 的最新版本比以前的版本更容易创建查询并且更具可读性。

You might want to look into what happens when MS stops developing LINQ to SQL,as it appears to be happening. SubSonics latest version is easier to create queries and more readable, then their previous version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文