Exemple #1
0
        public GridData GetData(GridOptions options)
        {
            int skipValue = ((options.Page - 1) * options.Rows);

            using (var ctx = new BaseballContext(_connectionString, _dbName, "complexBatter"))
            {
                var results = ctx.SelectAll <ExtendedBatter>()
                              .Where(b => b.Year > 2005)
                              .Take(500);

                return(CreateJSONStringForGridData(options, skipValue, results));
            }
        }
Exemple #2
0
        public GridData GetData2(GridOptions options)
        {
            int skipValue = ((options.Page - 1) * options.Rows);

            using (var ctx = new BaseballContext(_connectionString, _dbName, "complexBatter"))
            {
                IEnumerable <ExtendedBatter> results;
                if (options.IsSearch)
                {
                    if (options.Filters.FilterRules[0].Operation.Equals("eq"))
                    {
                        results = ctx.SelectAll <ExtendedBatter>()
                                  .Where(b => b.HomeRuns == Convert.ToInt32(options.Filters.FilterRules[0].FieldData));
                    }
                    else if (options.Filters.FilterRules[0].Operation.Equals("ne"))
                    {
                        results = ctx.SelectAll <ExtendedBatter>()
                                  .Where(b => b.HomeRuns != Convert.ToInt32(options.Filters.FilterRules[0].FieldData))
                                  .Take(500);
                    }
                    else
                    {
                        results = ctx.SelectAll <ExtendedBatter>()
                                  .Where(b => b.Year > 2005)
                                  .Take(500);
                    }
                }
                else
                {
                    results = ctx.SelectAll <ExtendedBatter>()
                              .Where(b => b.Year > 2005)
                              .Take(500);
                }

                return(CreateJSONStringForGridData(options, skipValue, results));
            }
        }
Exemple #3
0
        public GridData GetData3(GridOptions options)
        {
            int skipValue = ((options.Page - 1) * options.Rows);

            using (var ctx = new BaseballContext(_connectionString, _dbName, "complexBatter"))
            {
                IEnumerable <ExtendedBatter> results;
                Expression <Func <ExtendedBatter, bool> > predicate;

                if (options.IsSearch)
                {
                    predicate = SearchHelper.CreateSearchPredicate <ExtendedBatter>(_factory, options);
                }
                else
                {
                    predicate = b => b.Year > 2005;
                }

                results = ctx.SelectAll <ExtendedBatter>()
                          .AsExpandable()           //special thing for EF and Mongo
                          .Where(predicate);

                if (!String.IsNullOrWhiteSpace(options.SortIndex))
                {
                    if (options.SortOrder.Equals("asc", StringComparison.CurrentCultureIgnoreCase))
                    {
                        results = results.AsQueryable().OrderBy(SearchHelper.GetOrderByClause <ExtendedBatter, Int32>(options.SortIndex));
                    }
                    else
                    {
                        results = results.AsQueryable().OrderByDescending(SearchHelper.GetOrderByClause <ExtendedBatter, Int32>(options.SortIndex));
                    }
                }

                results = results.Take(500);

                return(CreateJSONStringForGridData(options, skipValue, results));
            }
        }