public static ObservableCollection<Categories> GetObservableCategories(TestDBEntities context) { ObservableCollection<Categories> tempCat = new ObservableCollection<Categories>(); var result = context.Categories.Select(category => category ) ; foreach (var category in result) { tempCat.Add(category); } ObservableCollection<Categories> Categories = tempCat; return Categories ; }
//public ObservableCollection<Customer> customer { get; set; } //public ObservableCollection<Customer> Customers { get; set; } public MainWindow() { TestDBEntities tdbe = new TestDBEntities(); Categories = TestClass.GetObservableCategories(tdbe); //var tupleList = TestClass.GetUnitCost(tdbe); // Categories2= new TestClass.GetCategories(); ; // Categories = new TestClass.GetObservableCategories(); InitializeComponent(); this.DataContext = this; //dgCust.ItemsSource = tupleList[0].Item3; }
public static List<Tuple<Nullable<decimal>, string, IEnumerable<Products>>> GetUnitCost(TestDBEntities context) { var query = from category in context.Categories join products in context.Products on category.CategoryID equals products.CategoryID into matches from match in matches select new Tuple<Nullable<decimal>, string, IEnumerable<Products>>(match.UnitCost, match.ModelName,matches); return query.ToList(); }
public static List<Categories> GetCategories() { TestDBEntities tdbe = new TestDBEntities(); var result = tdbe.Categories.Select(x => x).ToList(); return result; }