Solved

How to populate Entity from stored Proc Entity

Posted on 2014-11-14
1
126 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
ID: 40444027
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

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

20 Experts available now in Live!

Get 1:1 Help Now