public static ObjectDataProvider <TConnection, TDataParameter> GetProvider <TConnection, TDataParameter>( this DataProviderMetaData @this, ICache cache, SqlCommandGenerator sqlCommandGenerator) where TConnection : DbConnection, new() where TDataParameter : IDbDataParameter, new() { return(ObjectDataProviderFactory <TConnection, TDataParameter> .Get(@this.Type, cache, sqlCommandGenerator)); }
public ObjectDataProvider(Type type, ICache cache, SqlCommandGenerator sqlCommandGenerator) : base(cache) { entityType = type; SqlCommandGenerator = sqlCommandGenerator; MetaData = DataProviderMetaDataGenerator.Generate(type); DeleteCommand = SqlCommandGenerator.GenerateDeleteCommand(MetaData); UpdateCommand = SqlCommandGenerator.GenerateUpdateCommand(MetaData); InsertCommand = SqlCommandGenerator.GenerateInsertCommand(MetaData); PrepareTableTemplate(); PrepareFields(); PrepareColumnMappingDictonary(); }
static ObjectDataProvider <TConnection, TDataParameter> Create(Type type, ICache cache, SqlCommandGenerator sqlCommandGenerator) { var resultType = typeof(ObjectDataProvider <,>).MakeGenericType(typeof(TConnection), typeof(TDataParameter)); return((ObjectDataProvider <TConnection, TDataParameter>)Activator.CreateInstance(resultType, type, cache, sqlCommandGenerator)); }
public static ObjectDataProvider <TConnection, TDataParameter> Get(Type type, ICache cache, SqlCommandGenerator sqlCommandGenerator) { lock (Cache) { if (Cache.ContainsKey(type)) { return(Cache[type]); } var result = Create(type, cache, sqlCommandGenerator); Cache.Add(type, result); return(result); } }
public override string GenerateWhere(DatabaseQuery query) => SqlCommandGenerator.GenerateWhere(query);
public override string GenerateSelectCommand(IDatabaseQuery iquery, string fields) => SqlCommandGenerator.GenerateSelectCommand(iquery, GetTables(iquery.AliasPrefix), fields);