Solved

Can I see new   added   Entity before calling  SaveChanges method

Posted on 2014-11-17
1
75 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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