Reputation: 21
I get this error: "'TblProduct' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly." In the following code, and I am not sure why it is not working correctly. I was hoping someone might be able to help, Thanks!:
private void AddProductsToTabbedPanel()
{
int i = 1;
foreach (TabPage tp in tabControl1.TabPages)
{
ObjectQuery<TblProduct> filteredProduct = new ObjectQuery<TblProduct>("SELECT VALUE P FROM TblProduct AS P WHERE P.ProductType = " + i.ToString(), pse);
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
foreach (TblProduct tprod in filteredProduct)
{
Button b = new Button();
b.Size = new Size(100, 100);
b.Text = tprod.Description;
b.Tag = tprod;
b.Click += new EventHandler(UpdateProductList);
tp.Controls.Add(b);
}
Upvotes: 2
Views: 3453
Reputation: 289
You need to specify your TblProduct as a DbSet in your context.. from the information you have provided I guess that is what you have missed. It would be something like this..
public class ProductContext : DbContext
{
public DbSet<Category> TblCategories { get; set; }
public DbSet<Product> TblProduct { get; set; }
}
Upvotes: 1