【发布时间】:2010-03-30 05:02:54
【问题描述】:
以下是一些类和属性共享相同标识符的示例:
public Coordinates Coordinates { get; set; }
public Country Country { get; set; }
public Article Article { get; set; }
public Color Color { get; set; }
public Address Address { get; set; }
public Category Category { get; set; }
将 POCO 与实体框架一起使用时,此问题会更频繁地发生,因为实体框架使用关系的属性名称。
那该怎么办?使用非标准的类名?
public ClsCoordinates Coordinates { get; set; }
public ClsCountry Country { get; set; }
public ClsArticle Article { get; set; }
public ClsColor Color { get; set; }
public ClsAddress Address { get; set; }
public ClsCategory Category { get; set; }
呸
或者使用更具描述性的属性名称?
public Coordinates GeographicCoordinates { get; set; }
public Country GeographicCountry { get; set; }
public Article WebArticle { get; set; }
public Color BackgroundColor { get; set; }
public Address HomeAddress { get; set; }
public Category ProductCategory { get; set; }
不太理想,但我想可以忍受。
或者只是忍受它?
您的最佳做法是什么?
【问题讨论】:
标签: c# entity-framework class properties naming-conventions