在实体框架中排列列属性 [英] Ordering Column Attributes in Entity Framework
本文介绍了在实体框架中排列列属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在,我想订购它们,但是我找不到Order Attribute for Order中的属性。 >
我已经包括System.ComponentModel.DataAnnotations,但仍然没有得到它
提前感谢
解决方案
只需使用:
using System.ComponentModel .DataAnnotations.Schema;
代码:
code> [Column(Name,Order = 1)]
public int UserName {get;组;注意:默认情况下,cloumn arder需要一个大数字,所以如果你只订购了这个列,那么它将会是第一个在表中,除非您订购了另一列具有较低的订单号,这是在这种情况下:0I am using Entity Framework in my application,so I have mapped my property objects to database objects. The property objects have been defined using Column attribute.
Now,I want to order them,but I can't find the property in Column Attribute for Order.
I have included System.ComponentModel.DataAnnotations,but still not getting it
Thanks in advance
解决方案just use :
using System.ComponentModel.DataAnnotations.Schema;
Code :
[Column("Name" , Order = 1)] public int UserName { get; set; }
Notice : cloumn arder by default takes a big number so if you ordered only this column it will be first one in the table unless you ordered another column with a lower order number which is in this case : 0
这篇关于在实体框架中排列列属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文