Esempio n. 1
0
        /// <summary>
        /// Inherited IDataService Method
        /// </summary>
        /// <typeparam name="TLookup"></typeparam>
        /// <returns></returns>
        public override Task <List <string> > GetDistinctListAsync(DbDistinctRequest req)
        {
            var x = typeof(DbWeatherStation).GetProperty(req.FieldName);

            //=> await this.DBContext.CreateDbContext().GetDistinctListAsync(req);
            return(Task.FromResult(new List <string>()));
        }
        /// <summary>
        /// Inherited IDataService Method
        /// </summary>
        /// <typeparam name="TLookup"></typeparam>
        /// <returns></returns>
        public override Task <List <string> > GetDistinctListAsync(DbDistinctRequest req)
        {
            var x    = typeof(DbWeatherStation).GetProperty(req.FieldName);
            var list = this.Records.Select(item => item.Year.ToString()).Distinct().ToList();

            //=> await this.DBContext.CreateDbContext().GetDistinctListAsync(req);
            return(Task.FromResult(list));
        }
 public async Task <List <string> > GetDistinctListAsync([FromBody] DbDistinctRequest req) => await DataService.GetDistinctListAsync(req);
Esempio n. 4
0
 /// <summary>
 /// Inherited IDataService Method
 /// </summary>
 /// <typeparam name="TLookup"></typeparam>
 /// <returns></returns>
 public virtual async Task <List <string> > GetDistinctListAsync(DbDistinctRequest req) => await this.DBContext.CreateDbContext().GetDistinctListAsync(req);
Esempio n. 5
0
        /// <summary>
        /// Generic Method to get a record List count from a DbSet
        /// You must have a DbSet in your DBContext called dbSetName of type object
        /// public DbSet<object> DistinctList { get; set; }
        /// </summary>
        /// <typeparam name="TRecord"></typeparam>
        /// <param name="context"></param>
        /// <param name="dbSetName"></param>
        /// <returns></returns>
        public async static Task <List <string> > GetDistinctListAsync(this DbContext context, DbDistinctRequest req)
        {
            var list = new List <string>();

            // wrap in a try as there are many things that can go wrong
            try
            {
                //get the DbDistinct DB Set so we can load the query data into it
                var dbset = GetDbSet <DbDistinct>(context, req.DistinctSetName);
                // Get the data by building the SQL query to run against the view
                var dlist = await dbset.FromSqlRaw($"SELECT DISTINCT(CONVERT(varchar(max), {req.FieldName})) as Value FROM vw_{req.QuerySetName} ORDER BY Value").ToListAsync();

                // Load the results into a string list
                dlist.ForEach(item => list.Add(item.Value));
            }
            catch
            {
                throw new ArgumentException("The SQL Query did not complete.  The most likely cause is one of the DbDistinctRequest parameters is incorrect;");
            }
            return(list);
        }