Solved

How to populate Entity from stored Proc Entity

Posted on 2014-11-14
1
121 Views
Last Modified: 2014-11-17
I created  Entity  from database   Table Category
Auto generated code  is:
  public partial class StoreDBEntities : DbContext
    {
        public StoreDBEntities()
            : base("name=StoreDBEntities")
        {
        }
   
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
   
        public DbSet<Category> Categories { get; set; }
    }
 Now when I write   the following code all records are loaded into the  table which I do not want to happen

 StoreDBEntities ss = new StoreDBEntities();
               var cc = ss.Categories;
              List<Category> lc =  cc.ToList();

 
1)How to  populate entity from stored proc ?
2 How  to save entity   using stored proc?
0
Comment
Question by:Yampolka
1 Comment
 
LVL 7

Accepted Solution

by:
Camillia earned 500 total points
Comment Utility
You can rewrite your code without using a stored proc to limit the rows based on whatever condition you want


var cc = from p in StoreDBEntities.Categories
                where p.id = whatever  -- you can add your where clause here
               select p;

   return cc.ToList();

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now