v0.0.13 #4 - 修复和丰富 ICodeFirst.ConfigEntity 方法;

- 增加 FreeSql.Extensions.EFCoreModelBuilder 扩展库,现实与 EFCore 实体共存;
- 增加 FreeSql.RESTful.Demo 示例项目;
This commit is contained in:
28810
2019-02-14 19:07:52 +08:00
parent 45bc234160
commit 488a6edd4d
18 changed files with 190 additions and 22 deletions

View File

@ -40,9 +40,15 @@ namespace FreeSql.Internal {
entity?.Invoke(fluent);
return _orm.CodeFirst;
}
internal TableAttribute GetEntityTableAttribute(Type entityType) {
var attr = entityType.GetCustomAttributes(typeof(TableAttribute), false).LastOrDefault() as TableAttribute;
if (dicConfigEntity.TryGetValue(entityType, out var trytb) == false) return attr;
internal ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) {
var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
var fluent = new TableFluent(type, table);
entity?.Invoke(fluent);
return _orm.CodeFirst;
}
internal TableAttribute GetEntityTableAttribute(Type type) {
var attr = type.GetCustomAttributes(typeof(TableAttribute), false).LastOrDefault() as TableAttribute;
if (dicConfigEntity.TryGetValue(type, out var trytb) == false) return attr;
if (attr == null) attr = new TableAttribute();
if (string.IsNullOrEmpty(attr.Name)) attr.Name = trytb.Name;
@ -50,9 +56,9 @@ namespace FreeSql.Internal {
if (string.IsNullOrEmpty(attr.SelectFilter)) attr.SelectFilter = trytb.SelectFilter;
return attr;
}
internal ColumnAttribute GetEntityColumnAttribute(Type entityType, PropertyInfo proto) {
internal ColumnAttribute GetEntityColumnAttribute(Type type, PropertyInfo proto) {
var attr = proto.GetCustomAttributes(typeof(ColumnAttribute), false).LastOrDefault() as ColumnAttribute;
if (dicConfigEntity.TryGetValue(entityType, out var trytb) == false) return attr;
if (dicConfigEntity.TryGetValue(type, out var trytb) == false) return attr;
if (trytb._columns.TryGetValue(proto.Name, out var trycol) == false) return attr;
if (attr == null) attr = new ColumnAttribute();