Exemplo n.º 1
0
        public List <dynamic> getDynamicQuery(int id, DTO.SearchOptions o)
        {
            var rdef                  = dbset.Single(a => a.ID == id);
            var meta                  = SqlServerUtils.getMetadata(DataContext, rdef.sqlquery);
            var queryType             = buildQueryType(meta);
            Task <List <object> > raw = dbFactory.Get().Query <dynamic>().FromSql(
                //Task<List<object>> raw = db.Get().Database.SqlQuery(
                //queryType,
                rdef.sqlquery,
                new SqlParameter {
                ParameterName = "beginDate", Value = o.beginDate
            },
                new SqlParameter {
                ParameterName = "endDate", Value = o.endDate
            },
                new SqlParameter {
                ParameterName = "dwccardnum", Value = o.dwccardnum
            }).ToListAsync();

            // TODO catch exception and handle here
            raw.Wait();
            var results = raw.Result;

            return(results);
        }
Exemplo n.º 2
0
        public DataTable getDataTable(string query, DTO.SearchOptions o)
        {
            // https://stackoverflow.com/documentation/epplus/8223/filling-the-document-with-data
            DataTable dt   = new DataTable();
            var       cnxn = DataContext.Database.Connection.ConnectionString;

            using (SqlDataAdapter adapter = new SqlDataAdapter(query, cnxn))
            {
                adapter.Fill(dt);
            }
            return(dt);
        }