I am trying to develop a Sales and Inventory system using VS2015 c#. However, today I am getting errors. Here's my code:
public partial class Form4 : Form
{
private BindingList<tblProduct> products = new BindingList<tblProduct>();
private db_22VapeStreetEntities cse = new db_22VapeStreetEntities();
public Form4()
{
InitializeComponent();
lstProductsChosen.DataSource = products;
lstProductsChosen.DisplayMember = "Description";
createTabbedPanel();
}
private void AddProductsToTabbedPannel()
{
foreach (TabPage tp in tabControl1.TabPages)
{
ObjectQuery<tblProduct> filteredProduct = new ObjectQuery<tblProduct>("SELECT VALUE P FROM tblProducts AS P", cse);
}
The error is when I call the "cse" here --> ObjectQuery<tblProduct>("SELECT VALUE P FROM tblProducts AS P", cse);
I am getting
Argument 2: cannot convert from 'inventorysystem.db_22VapeStreetEntities' to 'System.Data.Objects.ObjectContext'
I tried searching the problem but I can't see any solutions.
From the little code you have posted, it is possible your entity context is actually a DBContext.
If that is the case, then try this
If you have a DBContext, try this Linq statement:
Or as you have omitted the actual filter syntax that you are using we can try something like this: