using Demo3.Models; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Demo3 { public class MainViewModel { private readonly ParsingdbContext _context; public ObservableCollection Products { get; } = new ObservableCollection(); public MainViewModel(ParsingdbContext context) { _context = context; LoadProducts(); } public void LoadProducts() { var products = _context.Products.ToList(); foreach (var product in products) { Products.Add(product); } } } }