Пример #1
0
 public Task<SearchDimensionItemViewModel> SearchDimensionAsync(Entity entity, string searchTerm)
 {
     return Task.Factory
                .StartNew(() => new SearchDimensionItemViewModel
                                {
                                    SearchTerm = searchTerm,
                                    Results = entity.Dimensions
                                                    .Where(x => x.Name.ToUpperInvariant().Contains(searchTerm.ToUpperInvariant()))
                                                    .ToArray()
                                });
 }
        public void ProductEntityGroupByProductName()
        {
            // new(Key.ProductName as ProductName,
            // Sum(UnitPrice) as UnitPrice,
            // Sum(UnitsInStock) as UnitsInStock,
            // Sum(UnitsOnOrder) as UnitsOnOrder,
            // Sum(ReorderLevel) as ReorderLevel
            var entity = new Entity("Products");
            var dimension = new Dimension("ProductName");
            entity.Dimensions.Add(dimension);
            entity.Measures.Add(new Measure("UnitPrice"));
            entity.Measures.Add(new Measure("UnitsInStock"));
            entity.Measures.Add(new Measure("UnitsOnOrder"));
            entity.Measures.Add(new Measure("ReorderLevel"));

            var query = new Query
            {
                DataSource = new DataSource {Name = "Northwind"},
                Entity = entity,
                GroupingDimensions = new[] {dimension},
            };

            var entityFrameworkQueryExecutor = new EntityFrameworkQueryExecutor().Execute(new MyDbContext(), query);
        }