Пример #1
0
        public static int Update <T>(this IDbCommand dbCmd, T obj, SqlExpressionVisitor <T> expression)
            where T : new()
        {
            IList <string> uf;

            if (expression.UpdateFields.Count == 0)
            {
                uf = expression.GetAllFields();
            }
            else
            {
                uf = expression.UpdateFields;
            }

            string sql = OrmLiteConfig.DialectProvider.ToUpdateRowStatement(obj, uf);

            if (!expression.WhereExpression.IsNullOrEmpty())
            {
                sql = sql + expression.WhereExpression;
            }
            return(dbCmd.ExecuteSql(sql));
        }
Пример #2
0
 public static T FirstOrDefault <T>(this IDbConnection dbConn, SqlExpressionVisitor <T> expression)
     where T : new()
 {
     return(dbConn.Exec(dbCmd => dbCmd.FirstOrDefault(expression)));
 }
Пример #3
0
 public static List <T> Select <T>(this IDbConnection dbConn, SqlExpressionVisitor <T> expression)
     where T : new()
 {
     return(dbConn.Exec(dbCmd => dbCmd.Select(expression)));
 }
        public static long Count <T>(this IDbConnection dbConn)
        {
            SqlExpressionVisitor <T> expression = OrmLiteConfig.DialectProvider.ExpressionVisitor <T>();

            return(dbConn.Exec(dbCmd => dbCmd.Count(expression)));
        }
 public static long Count <T>(this IDbConnection dbConn, SqlExpressionVisitor <T> expression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Count(expression)));
 }
 public static T First <T>(this IDbConnection dbConn, SqlExpressionVisitor <T> expression)
 {
     return(dbConn.Exec(dbCmd => dbCmd.First(expression)));
 }
Пример #7
0
        /// <summary>
        /// Delete the rows that matches the where expression, e.g:
        ///
        ///   var ev = OrmLiteConfig.DialectProvider.ExpressionVisitor&gt;Person&lt;());
        ///   dbCmd.Delete&lt;Person&gt;(ev.Where(p => p.Age == 27));
        ///   DELETE FROM "Person" WHERE ("Age" = 27)
        /// </summary>
        public static int Delete <T>(this IDbCommand dbCmd, SqlExpressionVisitor <T> where)
        {
            var sql = where.ToDeleteRowStatement();

            return(dbCmd.ExecuteSql(sql));
        }
Пример #8
0
        /// <summary>
        /// Using an Expression Visitor to only Insert the fields specified, e.g:
        ///
        ///   var ev = OrmLiteConfig.DialectProvider.ExpressionVisitor&gt;Person&lt;());
        ///   dbCmd.InsertOnly(new Person { FirstName = "Amy" }, ev.Insert(p => new { p.FirstName }));
        ///   INSERT INTO "Person" ("FirstName") VALUES ('Amy');
        /// </summary>
        public static void InsertOnly <T>(this IDbCommand dbCmd, T obj, SqlExpressionVisitor <T> onlyFields)
        {
            var sql = OrmLiteConfig.DialectProvider.ToInsertRowStatement(obj, onlyFields.InsertFields, dbCmd);

            dbCmd.ExecuteSql(sql);
        }
Пример #9
0
        public static long Count <T>(this IDbCommand dbCmd, SqlExpressionVisitor <T> expression)
        {
            string sql = expression.ToCountStatement();

            return(dbCmd.GetScalar <long>(sql));
        }
Пример #10
0
 public static int Delete <T>(this IDbConnection dbConn, SqlExpressionVisitor <T> where)
 {
     return(dbConn.Exec(dbCmd => dbCmd.Delete(where)));
 }
Пример #11
0
 public static void InsertOnly <T>(this IDbConnection dbConn, T obj, SqlExpressionVisitor <T> onlyFields)
 {
     dbConn.Exec(dbCmd => dbCmd.InsertOnly(obj, onlyFields));
 }
Пример #12
0
 public static int UpdateOnly <T>(this IDbConnection dbConn, T model, SqlExpressionVisitor <T> onlyFields)
 {
     return(dbConn.Exec(dbCmd => dbCmd.UpdateOnly(model, onlyFields)));
 }