/// <summary> /// 實體查詢物件取得 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="type">預設連線類型</param> /// <returns></returns> public static QueryContext <T> CreateInstance <T>(ConnectionType type = ConnectionType.Default) where T : class { var name = ConnectionSetting.GetConnection(type); DataProvider provider = ProviderFactory.CreateInstance(name); return(new QueryContext <T>(provider)); }
public string RegisterProvider(List <string> arguments) { Provider provider; try { provider = providerFactory.CreateInstance(arguments) as Provider; } catch (Exception e) { string propName = e.InnerException.TargetSite.Name.Substring(4); return($"Provider is not registered, because of it's {propName}"); } providers[arguments[1]] = provider; return($"Successfully registered {arguments[0]} Provider - {arguments[1]}"); }
private static DatabaseMeta CreateDatabaseMeta(DBType dbt, string connectionstring) { DatabaseMeta dbm = new DatabaseMeta(); dbm.ConnectionString = connectionstring; dbm.DBType = dbt; dbm.Tables = new List <TableMeta>(); IDBProvider provider = ProviderFactory.CreateInstance(dbm.DBType, connectionstring); string[] tables = provider.GetTables(); for (int i = 0; i < tables.Length; i++) { TableMeta tableMeta = new TableMeta(); tableMeta.TableName = tables[i]; tableMeta.Columns = provider.GetTableSchema(tableMeta.TableName); tableMeta.PrimaryKey = tableMeta.Columns.Where(t => t.IsKey).FirstOrDefault(); dbm.Tables.Add(tableMeta); } return(dbm); }