public MainViewModel(IBooksRepository booksRepository) : this() { if (IsInDesignMode) { return; } _booksRepository = booksRepository; SaveCommand = new RelayCommand(SaveChanges); LoadDataCommand = new RelayCommand(LoadData); Books.CollectionChanged += (sender, e) => { if (e.NewItems != null) { foreach (var item in e.NewItems) { var book = item as BookViewModel; if (book != null) { book.IsNew = true; } } } }; BooksQueriable = _booksRepository.GetAllBooksAsQueryable(); QueriableDataSource = new LinqServerModeDataSource() { QueryableSource = BooksQueriable }; }
protected override bool LoadData() { dataContext = DatabaseHelper.GetContext(); if (dataContext == null) { return(false); } try { LinqServerModeDataSource dataSource = new LinqServerModeDataSource(); dataSource.QueryableSource = dataContext.Sales; demo.pivotGrid.SetDataSourceAsync(dataSource); } catch { return(false); } return(true); }
protected object GetDataSource() { int i = (Session["DataSource"] != null) ? (int)Session["DataSource"] : 0; switch (i) { case 1: { LinqServerModeDataSource lnsource = new LinqServerModeDataSource { ContextTypeName = "NorthwindModel.NorthwindEntities", TableName = "Invoices" }; lnsource.Selecting += lnsource_Selecting; return(lnsource); } default: return(new EntityServerModeSource { QueryableSource = new NorthwindEntities().Orders, KeyExpression = "OrderID" }); } }