?
Solved

How to populate Entity from stored Proc Entity

Posted on 2014-11-14
1
Medium Priority
?
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
Camillia earned 2000 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

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