Beispiel #1
0
        public List <T> ToList <T>(DBBuilder dbBuilder, string sortExpression = null) where T : new()
        {
            if (sortExpression == null)
            {
                return(this.Do(dbBuilder, connection => connection.Query <T>(dbBuilder.GetCommand(DBAdapter)).ToList()));
            }

            dbBuilder.Compile(this.DBAdapter);
            var dbAnalyzer = DBAnalyzer.Init(dbBuilder.Sql, null, null, sortExpression);

            dbBuilder.Sql = dbAnalyzer.Select();
            return(this.Do(dbBuilder, connection => connection.Query <T>(dbBuilder.GetCommand(DBAdapter)).ToList()));
        }
Beispiel #2
0
 public void ToReader(DBBuilder dbBuilder, Action <IDataReader> action)
 {
     this.Do(dbBuilder, connection =>
     {
         var reader = connection.ExecuteReader(dbBuilder.GetCommand(DBAdapter));
         action(reader);
         return(reader);
     });
 }
Beispiel #3
0
 public DataTable ToDataTable(DBBuilder dbBuilder)
 {
     return(this.Do(dbBuilder, connection =>
     {
         DataTable dt = new DataTable();
         using (var reader = connection.ExecuteReader(dbBuilder.GetCommand(DBAdapter)))
         {
             dt.Load(reader);
         }
         return dt;
     }));
 }
Beispiel #4
0
 public int Execute(DBBuilder dbBuilder)
 {
     return(this.Do(dbBuilder, connection => connection.Execute(dbBuilder.GetCommand(DBAdapter))));
 }
Beispiel #5
0
 public object ToScalar(DBBuilder dbBuilder)
 {
     return(this.Do(dbBuilder, connection => connection.ExecuteScalar(dbBuilder.GetCommand(DBAdapter))));
 }