【发布时间】:2015-07-14 18:24:49
【问题描述】:
我尝试使用实体框架从数据库中获取一些值
我有疑问
实体框架查询中
new ClassName和new ClassName()的区别
代码 1
dbContext.StatusTypes.Select(s => new StatusTypeModel() { StatusTypeId =
s.StatusTypeId, StatusTypeName = s.StatusTypeName }).ToList();
代码 2
dbContext.StatusTypes.Select(s => new StatusTypeModel { StatusTypeId =
s.StatusTypeId, StatusTypeName = s.StatusTypeName }).ToList();
您可以从我创建 new StatusTypeModel 和 new StatusTypeModel() 对象的位置看到更改。
- 这两个查询都对我有用。但我不知道代码 1 和代码 2 之间的区别。
【问题讨论】:
标签: c# performance entity-framework class model-view-controller