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

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

问题描述

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

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?

推荐答案

您可以查看

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.

通常支持的某些:

Some of those generally supported:

  • 创建匿名类型. new { Person = x.Name }
  • First(). query.First()
  • FirstOrDefault(). query.FirstOrDefault()
  • Single(). query.Single()
  • SingleOrDefault(). query.SingleOrDefault()
  • Aggregate(). query.Aggregate((x1,x2) => x1)
  • Contains(). query.Where(x => x.Name.Contains("Foo"))
  • StartsWith().
  • EndsWith().
  • Substring(). where db.Methods.Substring(e.FirstName, 1, 2) == "An"
  • 子查询. query.Where(x => x.Company.Id == 4)
  • Count(). query.Where(x => x.Relatives.Count > 0)
  • Any(). query.Any()
  • Take(). query.Take(10)
  • 跳过(). query.Take(10).Skip(4)
  • OrderBy(). orderby x.Name descending
  • Replace(). AfterMethod = e.FirstName.Replace("An", "Zan"),
  • CharIndex(). where db.Methods.CharIndex(e.FirstName, 'A') == 1
  • IndexOf(). where e.FirstName.IndexOf("An") == 1
  • Anonymous type creation. new { Person = x.Name }
  • First(). query.First()
  • FirstOrDefault(). query.FirstOrDefault()
  • Single(). query.Single()
  • SingleOrDefault(). query.SingleOrDefault()
  • Aggregate(). query.Aggregate((x1,x2) => x1)
  • Contains(). query.Where(x => x.Name.Contains("Foo"))
  • StartsWith().
  • EndsWith().
  • Substring(). where db.Methods.Substring(e.FirstName, 1, 2) == "An"
  • Sub-queries. query.Where(x => x.Company.Id == 4)
  • Count(). query.Where(x => x.Relatives.Count > 0)
  • Any(). query.Any()
  • Take(). query.Take(10)
  • Skip(). query.Take(10).Skip(4)
  • OrderBy(). orderby x.Name descending
  • Replace(). 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.Linq提供程序所困扰,直到NHibernate 3.0(trunk)获得稳定版本并且我们感到足够安全为止在主要应用程序上使用它.在那之前,我对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天全站免登陆