How can you do paging with NHibernate?

For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this? ICriteria has a SetFirstResult(int i) method, which indicates the index of the first item that you wish to get (basically the first data row in your page). It also has a SetMaxResults(int i) method, which indicates the number of

你如何使用NHibernate进行分页?

例如,我想在ASP.NET网页中填充一个gridview控件,只显示显示的行数所需的数据。 NHibernate如何支持这个? ICriteria有一个SetFirstResult(int i)方法,它表示您希望获得的第一个项目的索引(基本上是页面中的第一个数据行)。 它还有一个SetMaxResults(int i)方法,它表示你希望得到的行数(即你的页面大小)。 例如,这个标准对象获取数据网格的前10个结果: criteria.SetFirstResult(0).SetMaxResults(10); 您还可

Explanation of NHibernate HiLo

I'm struggling to get my head round how the HiLo generator works in NHibernate. I've read the explanation here which made things a little clearer. My understanding is that each SessionFactory retrieves the high value from the database. This improves performance because we have access to IDs without hitting the database. The explanation from the above link also states: For instance

NHibernate HiLo的解释

我很努力让我的头脑如何HiLo生成器在NHibernate中工作。 我读过这里的解释,它使事情变得更加清晰。 我的理解是,每个SessionFactory都会从数据库中检索到较高的值。 这可以提高性能,因为我们可以在不碰到数据库的情况下访问ID。 上述链接的解释还说明: 例如,假设您有一个“高”序列,当前值为35,“低”数字在0-1023范围内。 然后,客户端可以将序列增加到36(对于其他客户端在使用35时能够生成密钥),并且知道35/0,3

Formatting a negative TimeSpan

I'm doing some math with the Timespans in .Net, and occasionally the sum results in a negative Timespan. When I display the result I am having trouble formatting it to include the negative indicator. Dim ts as New Timespan(-10,0,0) ts.ToString() This will display "-10:00:00", which is good but I don't want to show the seconds so tried this. ts.ToString("hh:mm") This return

格式化否定的TimeSpan

我正在使用.Net中的Timespans进行一些数学计算,偶尔会得出一个负的Timespan。 当我显示结果时,我无法格式化它以包含负面指标。 Dim ts as New Timespan(-10,0,0) ts.ToString() 这将显示“-10:00:00”,这很好,但我不想显示如此尝试的秒数。 ts.ToString("hh:mm") 这返回“10:00”,并从正面解决问题的核心 - “ - ”。 我目前的解决方案是: If(ts < TimeSpan.Zero, "-", "") & ts.ToString("hh:mm") 但我希望通

How can I String.Format a TimeSpan object with a custom format in .NET?

将TimeSpan对象格式化为具有自定义格式的字符串的推荐方式是什么? Please note: this answer is for .Net 4.0 and above. If you want to format a TimeSpan in .Net 3.5 or below please see JohannesH's answer. Custom TimeSpan format strings were introduced in .Net 4.0. You can find a full reference of available format specifiers at the MSDN Custom TimeSpan Format Strings page. Here's an examp

如何在.NET中使用自定义格式String.Format TimeSpan对象?

将TimeSpan对象格式化为具有自定义格式的字符串的推荐方式是什么? 请注意:这个答案适用于.Net 4.0及以上版本。 如果您想在.Net 3.5或更低版本中格式化TimeSpan,请参阅JohannesH的答案。 自定义TimeSpan格式字符串是在.NET 4.0中引入的。 您可以在MSDN Custom TimeSpan格式字符串页面找到可用格式说明符的完整参考。 以下是一个示例时间跨度格式字符串: string.Format("{0:hh\:mm\:ss}", myTimeSpan); //example output

ZeroMQ PUSH/PULL and lost message

I'm making use of ZeroMQ from .NET and got stuck trying to fix a weird issue. I've got a socket of type PUSH and one of type PULL over TCP. When the client disconnects, the server is still able to to send a message (note that no flags are passed to the Socket.Send method) which gets completely lots before starting to block and waiting for the client to reconnect and delivering messages

ZeroMQ PUSH / PULL并丢失消息

我正在使用.NET中的ZeroMQ,并试图修复一个奇怪的问题。 我有一个PUSH类型的套接字和一个TCP类型的PULL。 当客户端断开连接时,服务器仍然能够发送一条消息(请注意,没有标志传递给Socket.Send方法),在开始阻塞并等待客户端重新连接并传递消息之前,它会获得完全很多的信息事后发送。 我怎样才能避免丢失信息(或在最坏的情况下测试客户端是否连接,如果不发送虚拟信息,我可以承受)? 提前致谢! 编辑:进一步的测

How Random is System.Guid.NewGuid()? (Take two)

Before you start marking this as a duplicate, read me out. The other question has a (most likely) incorrect accepted answer. I do not know how .NET generates its GUIDs, probably only Microsoft does, but there's a high chance it simply calls CoCreateGuid(). That function however is documented to be calling UuidCreate(). And the algorithms for creating an UUID are pretty well documented.

随机是如何System.Guid.NewGuid()? (拿两个)

在开始将其标记为重复之前,请将我读出来。 另一个问题有一个(很可能)不正确的接受答案。 我不知道.NET如何生成它的GUID,可能只有微软,但它很可能只是调用CoCreateGuid()。 但是该函数被记录为调用UuidCreate()。 而且创建UUID的算法也有很好的文档记录。 长话短说,尽可能地,似乎System.Guid.NewGuid()确实使用版本4的UUID生成算法,因为它生成的所有GUID都与条件相匹配(请参阅我自己,我尝试了几百万个GUID,

Why is string.Join(string, object[]) special?

I was looking at the following expressions: string.Join(",", new object[] { null, "StackOverflow" }) string.Join(",", new string[] { null, "StackOverflow" }) string.Join(",", new object[] { string.Empty, "StackOverflow" }) string.Join(",", new string[] { string.Empty, "StackOverflow" }) I would have thought they would return the same value: ,StackOverflow However, the first expression actuall

为什么string.Join(string,object [])是特殊的?

我在看以下表达式: string.Join(",", new object[] { null, "StackOverflow" }) string.Join(",", new string[] { null, "StackOverflow" }) string.Join(",", new object[] { string.Empty, "StackOverflow" }) string.Join(",", new string[] { string.Empty, "StackOverflow" }) 我会认为他们会返回相同的价值: ,StackOverflow 但是,第一个表达式实际上返回string.Empty 。 这实际上是定义的行为: 如果值的第一个

SQL Server CE and Visual Studio 2013

So we now know that SQL Server CE is no longer supported with Visual Studio 2013. We can get some access to it via the SQL Server CE Toolbox add-in, but this does not fix the fact that a data provider is not included and thus we can no longer use SQL Server CE with Entity Framework etc. I haven't yet found an explanation from MS as to why this is now missing, but I've accepted it for no

SQL Server CE和Visual Studio 2013

因此,我们现在知道Visual Studio 2013不再支持SQL Server CE.我们可以通过SQL Server CE Toolbox加载项访问它,但这并不能解决数据提供者未包含的问题,因此我们不能再使用SQL Server CE和实体框架等。 我还没有从MS那里找到一个解释,为什么现在失踪了,但我现在已经接受了它,并且正在寻找继续前进的方法。 我的问题是 - 这个最好的迁移路径是什么? 我一直在使用SQL Server CE的数据优先实体框架,并部署小型网站,这些

[program name].exe has stopped working

I have a .NET application that was built on Framework 2.0. I've built an installer for it and am trying to run it on a machine that has 3.5. All relevant environments are on Windows 7 The application runs perfectly in VS debug mode on my development machine, which also has Framework 3.5. The installer runs fine on both my development machine and the user's machine After installa

[程序名称] .exe已停止工作

我有一个建立在Framework 2.0上的.NET应用程序。 我为它构建了一个安装程序,并试图在一台拥有3.5的计算机上运行它。 所有相关的环境都在Windows 7上 该应用程序在我的开发机器上以VS调试模式完美运行,该机器也具有Framework 3.5。 安装程序在我的开发机器和用户机器上运行良好 安装后,立即运行该程序导致“[程序名称] .exe已停止工作”,但没有进一步的信息 我让用户尝试安装Framework 2.0,但被“您必须使用启用/禁

MSBuild locking dll used on T4 template generated on build

I'm having a lot of trouble trying to identify why MSBuild is blocking access to a dll used inside a new T4 template I just created. The problem is kind of hard to explain (and even ask, as is evident by the title). I created a T4 template to generate ac# class that is a wrapper to N other classes we have. This was the solution I came up with to expose multiple WCF Services over the same

构建时生成的T4模板上使用的MSBuild锁定dll

我在尝试确定为什么MSBuild阻止访问在我刚刚创建的新T4模板中使用的dll时遇到了很多麻烦。 这个问题很难解释(甚至可以问,正如标题所显示的那样)。 我创建了一个T4模板来生成ac#类,它是我们拥有的其他N个类的包装器。 这是我提出的通过同一端点公开多个WCF服务的解决方案。 模板代码本身使用包含各种扩展方法的程序集(Mobiltec.Framework.dll)来简化模板代码。 起初,我只是将一个.tt文件添加到项目中,并随它一起