NHibernate.LINQ 支持的运算符 [英] NHibernate.LINQ Supported Operators

查看:15
本文介绍了NHibernate.LINQ 支持的运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在不实际编写任何代码的情况下评估 NHibernate.LINQ 1.0.Ayende 承认 这个版本的 LINQ与 EF 相比,支持低于 EF,但在我的一生中,我似乎找不到一个页面来解释此实现中支持和不支持的内容.例如,我可以使用 Skip &?我不能使用什么?

I'm trying to evaluate NHibernate.LINQ 1.0 without actually writing any code. Ayende has admitted that this version of LINQ support is subpar compared to EF, but for the life of me I can't seem to find a page that explains what's supported and unsupported in this implementation. For example, can I use Skip & Take? What can I not use?

推荐答案

您可以查看 LINQ for NHibernate 示例,查看 Ayende 自己对已实现的内容和不适合该提供程序的内容进行的测试.

You can check LINQ for NHibernate examples to see tests done by Ayende himself on what's implemented and what's not for this provider.

其中一些一般支持:

  • 匿名类型创建.new { Person = x.Name }
  • 第一个().query.First()
  • FirstOrDefault().query.FirstOrDefault()
  • 单().query.Single()
  • SingleOrDefault().query.SingleOrDefault()
  • 聚合().query.Aggregate((x1,x2) => x1)
  • 包含().query.Where(x => x.Name.Contains("Foo"))
  • StartsWith().
  • EndsWith().
  • 子字符串().where db.Methods.Substring(e.FirstName, 1, 2) == "An"
  • 子查询.query.Where(x => x.Company.Id == 4)
  • 计数().query.Where(x => x.Relatives.Count > 0)
  • 任何().query.Any()
  • 取().query.Take(10)
  • 跳过().query.Take(10).Skip(4)
  • OrderBy().orderby x.Name 降序
  • 替换().AfterMethod = e.FirstName.Replace("An", "Zan"),
  • CharIndex().where db.Methods.CharIndex(e.FirstName, 'A') == 1
  • IndexOf().where e.FirstName.IndexOf("An") == 1

有问题:

  • 分组依据
  • 加入

我自己的一个例子:

query = NSession.Session.Linq<Catalog>()
            .Where(acc => acc.Company.Status == "A")
        .Where(acc => acc.Id.StartsWith("12-536"))
        .Where(acc => acc.Id.EndsWith("92") || acc.Id.EndsWith("67"))
        .Take(10).OrderBy(acc => acc.Title);

如果您的生产应用程序像我一样使用最新的稳定版本 2.1.2.4,那么在 NHibernate 3.0(主干)获得稳定版本并且我们感到足够安全之前,您会坚持使用 NHibernate.Linq 提供程序提供给我们的内容在主要应用程序中使用它.在那之前,我对 NHibernate.Linq 和 HQL 的混合感到非常满意.

If you're production application is using the latest stable build 2.1.2.4 like I am, you're stuck with what the NHibernate.Linq provider gives us until NHibernate 3.0 (trunk) gets a stable release and we feel safe enough to use it on major applications. Until then, I'm more than happy with a mixture of NHibernate.Linq and HQL.

这篇关于NHibernate.LINQ 支持的运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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