상속: IHelperOptions
예제 #1
0
 public SelectBuilderTests()
 {
     _opt=new HelperOptions();
     _prov=new FakeDbProvider();
     _writer=new FakeWriter();
     _sut =new SimpleSqlBuilder<Post>(_opt,_prov,Setup.GetTableInfo<Post>(),_writer);
 }
예제 #2
0
        public static IBuildUpdateTable <T> Update <T>(this DbConnection db, Action <IHelperOptions> cfg = null) where T : class
        {
            var opt = new HelperOptions(db.GetPocoInfo <T>());

            cfg?.Invoke(opt);
            var executor = new CustomSqlExecutor(db);

            return(new UpdateTableBuilder <T>(executor, db.GetExpressionSqlGenerator(), db.Provider(), opt));
        }
예제 #3
0
 public UpdateBuilderTests(ITestOutputHelper x)
 {
     _writer = Setup.FakeWriter();
     _sb = new StringBuilder();
   
     _executor = new FakeSqlExecutor();
     _options = new HelperOptions();
     _options.EnsureTableName(Setup.GetTableInfo<Post>());
     _sut = new UpdateTableBuilder<Post>(_executor, _writer, new FakeEscapeIdentifier(), _options);
 }
예제 #4
0
        public static int DeleteFromAnonymous <T>(this DbConnection db, T data, Action <IHelperOptions> opt, Expression <Func <T, bool> > criteria = null)
        {
            var options = new HelperOptions();

            opt(options);
            var name    = db.Provider().EscapeTableName(new TableName(options.TableName, options.DbSchema));
            var builder = new DeleteTableBuilder(name, db.GetExpressionSqlGenerator());

            if (criteria != null)
            {
                builder.WriteCriteria(criteria);
            }
            return(db.Execute(builder.GetCommandConfiguration()));
        }
예제 #5
0
        /// <summary>
        /// Perform update table with data from an anonymous object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="columns">Select which columns to update from an anonymous object</param>
        /// <param name="cfg">Configure name and other</param>
        /// <returns></returns>
        public static IBuildUpdateTableFrom <T> UpdateFrom <T>(this DbConnection db, Func <IUpdateColumns, IColumnsToUpdate <T> > columns, Action <IHelperOptions> cfg) where  T : class
        {
            var options = new HelperOptions();
            var u       = new UpdateColumns();

            cfg(options);
            options.EnsureTableName(db.GetPocoInfo <T>());
            var builder  = columns(u) as UpdateColumns.CreateBuilder <T>;
            var executor = new CustomSqlExecutor(db);
            var updater  = new UpdateTableBuilder <T>(executor, db.GetExpressionSqlGenerator(), db.Provider(), options);

            builder.PopulateBuilder(updater);
            return(updater);
        }
예제 #6
0
        /// <summary>
        /// Perform update table with data from an anonymous object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="db"></param>
        /// <param name="valuesToUpdate"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static IBuildAnonymousUpdate UpdateFrom <T>(this DbConnection db, T valuesToUpdate, TableName tableName) where  T : class
        {
            tableName.MustNotBeNull();
            var options = new HelperOptions(db.GetPocoInfo <T>());

            options.TableName = tableName;

            var executor = new CustomSqlExecutor(db);
            var updater  = new UpdateTableBuilder <T>(executor, db.GetExpressionSqlGenerator(), db.Provider(), options);

            updater.SetUpdates(valuesToUpdate);

            return(new UpdateAnonymousBuilder <T>(updater));
        }