0
我们目前在剥开从我们的应用程序功能NHibernate的过程中,由于部分信任的问题。我们正在使用流利的API转向Entity Framework 5.1RC。NHibernate的查询等效实体框架查询
我们已经在我们的资料库下面的方法,我试图如果相同的查询可以使用实体框架编写找出?我显然希望它尽可能高效。
public PagedList<Topic> GetRecentTopics(int pageIndex, int pageSize, int amountToTake)
{
// Get a delayed row count
var rowCount = Session.QueryOver<Topic>()
.Select(Projections.RowCount())
.Cacheable()
.FutureValue<int>();
// Get the topics using an efficient query
var results = Session.QueryOver<Topic>()
.OrderBy(x => x.CreateDate).Desc
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize)
.Cacheable()
.Future<Topic>().ToList();
// We might only want to display the top 100
// but there might not be 100 topics
var total = rowCount.Value;
if (total > amountToTake)
{
total = amountToTake;
}
// Return a paged list
return new PagedList<Topic>(results, pageIndex, pageSize, total);
}
任何帮助/指针非常感谢。
谢谢,我们已经尝试了一切,流利的nhibernate不会在中等信任下工作。 – leen3o 2012-07-11 14:15:48
正在从FNH生成xml并将其嵌入为资源选项?或者序列化配置对象并使用它? – Firo 2012-07-12 06:27:53
感谢您回来,我们花了好几天的时间尝试各种配置,而只是将其翻出来,现在使用EF。 – leen3o 2012-07-12 18:34:02