映射到日期而不是CTP5中的DateTime [英] Mapping to a Date instead of DateTime in CTP5

查看:72
本文介绍了映射到日期而不是CTP5中的DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的某个模型上有一个Birthdate属性,并希望它映射到SQL中的Date字段。


我尝试使用  [DataType(DataType。)进行装饰。日期)],但没有用。后来我想出了这个方法 -   modelBuilder.Entity< Client>()。Property(p => p.BirthDate).HasColumnType(" date"); - 工作正常。


支持[DataType]属性提示数据类型是不是有意义?


Chris Sutton

解决方案

Chris,


 


感谢您的建议。我们将考虑增加对此的支持。


 


亚瑟


I have a Birthdate property on one of my models and wanted it to map to a Date field in SQL.

I tried decorating it with [DataType(DataType.Date)], which didn't work. Later I figured out this method - modelBuilder.Entity<Client>().Property(p => p.BirthDate).HasColumnType("date"); - which worked fine.

Wouldn't it make sense to support the [DataType] attribute to hint the datatype?

Chris Sutton

解决方案

Chris,

 

Thanks for the suggestion. We will consider adding support for this.

 

Arthur


这篇关于映射到日期而不是CTP5中的DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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