Solved

Can I see new   added   Entity before calling  SaveChanges method

Posted on 2014-11-17
1
74 Views
Last Modified: 2014-12-09
I have Table Orders
I should allow user to add new Order , fill out it first and then Save Changes to to Database
I am working in EF5

how to I insert Entity  in  Entity Context before calling SaveChanges method?
Thanks.
0
Comment
Question by:Yampolka
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40448439
You can do something like this.

DcContextInstanceName.EntityTableName.Add(newlyCreatedEntity);

db.Orders.Add(newOrder);

Where db is the instance of the DbContext Orders is the entity class that maps to the database and newOrder is an instance of the Order table entity.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
There is a huge demand for CodeIgniter among the PHP web developers due to its dynamic features and benefits these days. It is one of most popular and agile open source PHP framework for creating robust web applications in PHP web development field.…
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…

856 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