Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
IN EF , Is it possible to Connect Both database and ClassFile With Data.

How we can read Data from Class File. I want to pass context so that which one need to connect will be known.

XML
private List<ItemList>GetDefaultCategory(ISampleDataDB dbContext)
        {
            List<ItemList> Result = new List<ItemList>();
            Result = (from p in dbContext.Item
                      where p.HouseID.Equals(1) && p.ItemorCategory.Equals(2)
                      select new ItemList { ItemId = p.ItemID, ItemCode = p.Name }).AsQueryable().ToList<ItemList>();

            return Result;
        }



Here iSampledataDb is an interface with properties . I want to use the same method by passing object of DbContext(Entity Framework)

TestContext dbContext = new TestContext();

GetDefaultCategory(dbContext);

Is it possible or any other alternative is available
Posted
Updated 28-Sep-15 7:03am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900