Demo/Demo3/MainViewModel.cs
2024-12-27 13:32:41 +03:00

33 lines
756 B
C#

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<Product> Products { get; } = new ObservableCollection<Product>();
public MainViewModel(ParsingdbContext context)
{
_context = context;
LoadProducts();
}
public void LoadProducts()
{
var products = _context.Products.ToList();
foreach (var product in products)
{
Products.Add(product);
}
}
}
}