## v0.9.17 (ODBC)

- 增加 FreeSql.Provider.Odbc,实现 Oracle/SqlServer/MySql 的 Odbc 访问提供;
- 增加 FreeSqlBuilder.UseConnectionString 参数 providerType,可解决因包版本冲突时,可能无法反射获得 FreeSql.Provider 对应的类型,通常这个参数不需要设置;
- 优化 MaxLength 特性,当指定为 -1 时 DbType 会分别映射类型 text/nvarchar(max)/nvarchar2(4000);
This commit is contained in:
28810
2019-09-19 23:14:30 +08:00
parent 8d92ccd751
commit f434418b2c
123 changed files with 31796 additions and 112 deletions

View File

@ -31,7 +31,7 @@ namespace FreeSql.Internal.CommonProvider
public bool IsSyncStructureToLower { get; set; } = false;
public bool IsSyncStructureToUpper { get; set; } = false;
public bool IsConfigEntityFromDbFirst { get; set; } = false;
public bool IsNoneCommandParameter { get; set; } = false;
public virtual bool IsNoneCommandParameter { get; set; } = false;
public bool IsLazyLoading { get; set; } = false;
public abstract (int type, string dbtype, string dbtypeFull, bool? isnullable, object defaultValue)? GetDbInfo(Type type);
@ -50,7 +50,7 @@ namespace FreeSql.Internal.CommonProvider
public bool SyncStructure(params Type[] entityTypes)
{
if (entityTypes == null) return false;
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a) == false && GetTableByEntity(a)?.DisableSyncStructure == false).ToArray();
var syncTypes = entityTypes.Where(a => dicSyced.ContainsKey(a) == false && GetTableByEntity(a)?.DisableSyncStructure == false).ToArray().Distinct().ToArray();
if (syncTypes.Any() == false) return false;
var before = new Aop.SyncStructureBeforeEventArgs(entityTypes);
_orm.Aop.SyncStructureBefore?.Invoke(this, before);
@ -66,7 +66,7 @@ namespace FreeSql.Internal.CommonProvider
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType, true);
return true;
}
var affrows = _orm.Ado.ExecuteNonQuery(CommandType.Text, ddl);
var affrows = ExecuteDDLStatements(ddl);
foreach (var syncType in syncTypes) dicSyced.TryAdd(syncType, true);
return true;
}
@ -82,5 +82,7 @@ namespace FreeSql.Internal.CommonProvider
_orm.Aop.SyncStructureAfter?.Invoke(this, after);
}
}
public virtual int ExecuteDDLStatements(string ddl) => _orm.Ado.ExecuteNonQuery(CommandType.Text, ddl);
}
}

View File

@ -76,7 +76,7 @@ namespace FreeSql.Internal
var setMethod = trytb.Type.GetMethod($"set_{p.Name}");
var colattr = common.GetEntityColumnAttribute(entity, p);
var tp = common.CodeFirst.GetDbInfo(colattr?.MapType ?? p.PropertyType);
if (setMethod == null) // 属性没有 set自动忽略
if (setMethod == null || (tp == null && p.PropertyType.IsValueType)) // 属性没有 set自动忽略
{
if (colattr == null) colattr = new ColumnAttribute { IsIgnore = true };
else colattr.IsIgnore = true;
@ -976,7 +976,7 @@ namespace FreeSql.Internal
var ps = type.GetProperties();
foreach (var p in ps)
{
if (sql.IndexOf($"{paramPrefix}{p.Name}", StringComparison.CurrentCultureIgnoreCase) == -1) continue;
if (string.IsNullOrEmpty(paramPrefix) == false && sql.IndexOf($"{paramPrefix}{p.Name}", StringComparison.CurrentCultureIgnoreCase) == -1) continue;
var pvalue = p.GetValue(obj);
if (p.PropertyType == ttype) ret.Add((T)Convert.ChangeType(pvalue, ttype));
else ret.Add(constructorParamter(p.Name, p.PropertyType, pvalue));