private void PrepareSql(string sqlText, object obj, CommandType type = CommandType.Text) { sql = new SqlEntity(sqlText, type: type); sql.Type = Type; sql.OnDbBefore = Log; sql.OnDbError = Error; sql.CommandTimeout = CommandTimeout; if (obj == null) { return; } if (obj is SqlParameterEntity) { sql.AddParameter(obj as SqlParameterEntity); } else if (obj is IDictionary <string, object> ) { sql.AddParameters(obj as IDictionary <string, object>); } else if (obj is IEnumerable) { Type objType = obj.GetType(); bool isSqlObj = objType.GetGenericArguments().Any(m => m == typeof(SqlParameterEntity)); if (isSqlObj) { sql.AddParameters(obj as IEnumerable <SqlParameterEntity>); } } else { sql.AddParameter(obj); } db.UpdateSqlEntity(sql); }
public void Dispose() { sql = null; db.Dispose(); }