Why is DateTime.Now.Year an int and not a ushort

In the .Net framework DateTime structure, the Year is defined as an int (which is really A System.Int32). However, the MSDN documentation says that the value will always be between 1 and 9999. Thus, a ushort (System.UInt16) is more than adequate to store the value and takes up half the space. So why is it an int and not a ushort? There is an implicit conversion from ushort to int so there is

为什么DateTime.Now.Year是int而不是ushort

在.Net框架的DateTime结构中,年被定义为一个int(这实际上是一个System.Int32)。 但是,MSDN文档说该值始终在1和9999之间。因此,ushort(System.UInt16)足以存储该值并占用一半的空间。 那么为什么它是一个整数,而不是一个ushort? 有一个从ushort到int的隐式转换,因此没有需要做的转换来完成年度的整数运算。 我意识到这是一个微型优化问题,因此不是很重要。 我只是好奇。 因此,一个ushort(System.UInt16)绰

How to Detect and Resolve Incorrectly Encoded Varchar Data?

My company has a CRM product that is built on top of a third party webmail system. We use their underlying database, and have extended it with additional databases of our own. As well as using our product, clients are able to log into the webmail system directly. The webmail databases are SQL_Latin1_General_CP1_CI_AS encoded and contact names are stored in varchar columns, not nvarchar. bot

如何检测和解决错误编码的Varchar数据?

我的公司有一个建立在第三方网络邮件系统之上的CRM产品。 我们使用他们的底层数据库,并用我们自己的其他数据库扩展它。 除了使用我们的产品,客户还可以直接登录到webmail系统。 Webmail数据库是SQL_Latin1_General_CP1_CI_AS编码的,联系人名称存储在varchar列中,而不是nvarchar。 我们的产品和webmail产品都提供Content-Type:text / html charset = utf-8的页面 如果客户在名为“Céline”的网络邮件(第三方系统)中

What does Html.HiddenFor do?

Although I have read the documentation on Html.HiddenFor, I've not grasped what is it used for... Could somebody explain its uses and give a short example? Where should those helpers go in the code? It creates a hidden input on the form for the field (from your model) that you pass it. It is useful for fields in your Model/ViewModel that you need to persist on the page and have passed

Html.HiddenFor做什么?

虽然我已经阅读了关于Html.HiddenFor的文档,但我没有理解它用于... 有人可以解释它的用途并举一个简短的例子吗? 这些助手应该在代码中进入哪里? 它会在表单中为您传递的字段(来自您的模型)创建一个隐藏输入。 对于您的Model / ViewModel中的字段,您需要在页面上保留并在另一个调用进行但不应被用户看到时返回。 考虑下面的ViewModel类: public class ViewModel { public string Value { get; set; } pu

Why should I use nhibernate instead of entity framework 4

I'm trying to convince my client to use nhibernate instead of Entity Framework 4. My client have decided to use only Microsoft libraries (including Unity and Enterprise library 5). I don't agree with them (there are so much better logging frameworks/validation layers/ioc etc) but respect their decision. I've played with EF4 for a couple of days and I do not like it, mainly because

为什么我应该使用nhibernate而不是实体框架4

我试图说服我的客户端使用nhibernate而不是实体框架4.我的客户端决定只使用Microsoft库(包括Unity和Enterprise库5)。 我不同意他们(有更好的日志框架/验证层/ ioc等),但尊重他们的决定。 我已经和EF4玩了几天,我不喜欢它,主要是因为: 首先,所有的错误信息都很糟糕。 我不得不花更多时间搜索例外情况,而不是尝试修正它们。 我们使用POCO,使EF4能够正常工作是一件麻烦事。 nhibernate使用的映射文件非常容易

Entity Framework 4, defining relationship

When defining a relationship in entity framework 4 in a 1-to-many relationship using POCO classes why does the relationship have to be defined at the child level. for example say we have an order that has many products. The relationship in the mapping file for the product would look like:- Relationship(e => e.Order) .FromProperty(m => m.Product) .HasConstraint

实体框架4,定义关系

当使用POCO类以1对多关系定义实体框架4中的关系时,为什么必须在子级别定义关系。 例如说我们有一个有很多产品的订单。 产品映射文件中的关系如下所示: - Relationship(e => e.Order) .FromProperty(m => m.Product) .HasConstraint((e, m) => e.Id == m.Id); 在n-hibernate中,它在父级别的映射文件中定义(在这种情况下为Order)。 在父级定义的关系提供了更大的灵活性和重用性。

Making your .NET language step correctly in the debugger

Firstly, I apologize for the length of this question. I am the author of IronScheme. Recently I have been working hard on emitting decent debug info, so that I can use the 'native' .NET debugger. While this has been partly successful, I am running into some teething problems. The first problem is related to stepping. Due to Scheme being an expression language, everything tends to

在调试器中正确地使你的.NET语言步骤正确

首先,我对这个问题的长度表示歉意。 我是IronScheme的作者。 最近我一直在努力发布体面的调试信息,以便我可以使用“本地”.NET调试器。 虽然这部分取得了成功,但我遇到了一些初期问题。 第一个问题与步进有关。 由于Scheme是一种表达式语言,所有东西都倾向于包装在括号中,而不像主要的.NET语言,它似乎是基于语句(或行)。 原始代码(Scheme)看起来像: (define (baz x) (cond [(null? x) x] [

Consume .NET assembly in Delphi XE2

I have some of the business logic implemented in .NET and some in Delphi. Now i am planning to upgrade to Delphi XE2. Do we have any provision to consume .net assembly from Delphi XE2? Update: I heard about Hydra framework which enable us to integrate managed and unmanaged code. Can anyone explain more about it with a small demo / code snippet? Update: I have tried few things on Trial ver

在Delphi XE2中使用.NET程序集

我有一些在.NET中实现的业务逻辑,还有一些在Delphi中实现。 现在我打算升级到Delphi XE2。 我们是否有任何规定可以从Delphi XE2中使用.net程序集? 更新:我听说过Hydra框架 ,它使我们能够集成托管代码和非托管代码。 任何人都可以用一个小的演示/代码片段来解释更多吗? 更新:我在这个Hydra框架的试用版上尝试了一些东西。 但它需要修改您的.NET程序集以创建接口,以便我们可以将其与Delphi代码进行映射。 有没有

Does Sandcastle support code contracts?

My library uses code contracts. Is there a way to incorporate these contracts in the documentation generated by sandcastle? Edit: Turns out this method is outdated; just install Sandcastle Styles. Sandcastle doesn't support it natively but Code Contracts comes with the required files. First ensure you are generating documentation for your assembly, then in the Code Contracts settings

Sandcastle是否支持代码合同?

我的图书馆使用代码合同。 有没有办法将这些合同纳入sandcastle生成的文档中? 编辑:原来这个方法已经过时了; 只需安装Sandcastle Styles。 Sandcastle本身不支持它,但Code Contracts附带所需的文件。 首先确保您为您的程序集生成文档,然后在项目的代码合同设置中,将合同参考大会设置为“生成”,并选中“将合同放入XML文档文件”复选框。 接下来,打开C:Program Files (x86)MicrosoftContractsSandcastleSandcastle.

Ignore some properties in runtime when using DataContractSerializer

I am using DataContractSerializer to serialize an object to XML using DataMember attribute (only public properties are serialized). Is it possible to dynamically ignore some properties so that they won't be included in the XML output? For example, to allow user to select desired xml elements in some list control and then to serialize only those elements user selected excluding all that ar

使用DataContractSerializer时,忽略运行时的某些属性

我正在使用DataContractSerializer将对象序列化为使用DataMember属性的XML(仅公共属性被序列化)。 是否可以动态地忽略一些属性,以便它们不会包含在XML输出中? 例如,允许用户在某些列表控件中选择所需的xml元素,然后仅序列化用户选择的那些元素,排除所有未选中的元素。 谢谢 对于列表场景,可能只是具有不同的属性,而不是: [DataMember] public List<Whatever> Items {get {...}} 你有: public List<

How to setup build/deployment for .net project on Jenkins

We currently uses Jenkins for all our (Java) build/deployment from a Linux box. Now we are building a .net client and would like to have a similar automated build/deployment process. I have some research and found the MSBuild plugin for Jenkins. There seems to be two ways to proceed: Install Wine or other VM for Windows on the linux box, then install .net framework so Jenkins can use it for

如何在Jenkins上为.net项目设置构建/部署

我们目前使用Jenkins来从Linux机器中完成所有(Java)构建/部署。 现在我们正在构建.net客户端,并且希望有一个类似的自动构建/部署过程。 我有一些研究,并找到了詹金斯的MSBuild插件。 似乎有两种方法可以进行: 在Linux机器上安装Wine或其他VM for Windows,然后安装.net框架,以便Jenkins可以将它用于MSBuild 在Windows机器上安装一个Jenkins的新实例,并有一个独立的构建平台。 我对.net的奇妙世界相当陌生,因此