Reputation: 123
This is first time I am trying EF core. I create separate class library for EF core created dbcontext EXPENSEDBContext
class form the existing database and build successfully.
While I tried to select a record through the object of EXPENSEDBContext
I could not able to see the Select()
and Where()
as below
var selectvalues = db.Category.Select();
So as an alternate I used foreach instead of Select()
as below
using (var db = new EXPENSEDBContext())
{
//
var selectvalues = db.Category;
foreach(var b in selectvalues)
{
Console.WriteLine(b.Name);
}
}
My question is why Select
method is not poping up in db.Category
.
Upvotes: 1
Views: 361
Reputation: 23190
If you correctly defined Category
property as you said in your comment
public virtual DbSet<Catagory> Catagory { get; set; }
so make sure you added the following using statement:
using System.Linq;
If it doesn't compile so make sure to install the System.Linq nuget package:
Install-Package System.Linq
Upvotes: 3