pgsql CodeFirst 适配中

This commit is contained in:
28810
2018-12-19 19:34:52 +08:00
parent 4e45bb184e
commit 6f8a047149
8 changed files with 164 additions and 50 deletions

View File

@ -27,17 +27,20 @@ namespace FreeSql.Internal {
trytb.SelectFilter = tbattr?.SelectFilter;
foreach (var p in trytb.Properties.Values) {
var tp = common.CodeFirst.GetDbInfo(p.PropertyType);
if (tp == null) continue;
var colattr = p.GetCustomAttributes(typeof(ColumnAttribute), false).LastOrDefault() as ColumnAttribute ?? new ColumnAttribute {
Name = p.Name,
DbType = tp.Value.dbtypeFull,
IsIdentity = false,
IsNullable = tp.Value.isnullable ?? false,
IsPrimary = false,
};
//if (tp == null) continue;
var colattr = p.GetCustomAttributes(typeof(ColumnAttribute), false).LastOrDefault() as ColumnAttribute;
if (tp == null && colattr == null) continue;
if (colattr == null)
colattr = new ColumnAttribute {
Name = p.Name,
DbType = tp.Value.dbtypeFull,
IsIdentity = false,
IsNullable = tp.Value.isnullable ?? false,
IsPrimary = false,
};
if (string.IsNullOrEmpty(colattr.Name)) colattr.Name = p.Name;
if (string.IsNullOrEmpty(colattr.DbType)) colattr.DbType = tp.Value.dbtypeFull;
if (colattr.DbType.IndexOf("NOT NULL") == -1 && tp.Value.isnullable == false) colattr.DbType += " NOT NULL";
if (string.IsNullOrEmpty(colattr.DbType)) colattr.DbType = tp?.dbtypeFull ?? "varchar(255)";
if (colattr.DbType.IndexOf("NOT NULL") == -1 && tp?.isnullable == false) colattr.DbType += " NOT NULL";
var col = new ColumnInfo {
Table = trytb,