Answer the question
In order to leave comments, you need to log in
How to implement queries in WinForms Entity Framework?
I need to display the query in the dataGridView, but I don’t know how to do it.
I’m looking on the Internet, and they write how to do it in the console, but I need it in WinForms, I tried to implement it in Winforms, but nothing happens.
At first I thought that it was possible to call a stored procedure that I create in MSSMS, but this did not work, because only found with database first even though my model is code first
Tried LinQ to Entities but that doesn't work either, what am I doing wrong?
Throws error CS1936 Could not find an implementation of the query pattern for source type 'DbSet'. 'Select' not found.
Here is the code
ClientContext db;
private void button1_Click(object sender, EventArgs e)
{
var clients = (from Clients in db.Clientss select clients).ToList();
}
using System.Data.Entity;
namespace FurnitureBApp
{
class ClientContext : DbContext
{
public ClientContext() : base("FurnitureDb")
{ }
public DbSet<Clients> Clientss { get; set; }
public DbSet<Orders> Orderss { get; set; }
public DbSet<Furniture> Furnitures { get; set; }
public DbSet<FurnitureType> FurnitureTypes { get; set; }
}
}
Answer the question
In order to leave comments, you need to log in
Please ask if it's not clear.
https://docs.microsoft.com/ru-ru/dotnet/api/system...
private static int _interval = 60;
private static DatabaseCtx _ctx = DatabaseCtx.Instance;
public static BindingList<Data> Items { get; set; } = new BindingList<Data>();
public ExportGridForm()
{
InitializeComponent();
ReloadData();
bindingSource1.DataSource = Items;
}
private void ReloadData()
{
Items.Clear();
foreach (var data in _ctx.GetDatas()) Items.Add(data);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question