33 lines
756 B
C#
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|