Solved

Can I see new   added   Entity before calling  SaveChanges method

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

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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

19 Experts available now in Live!

Get 1:1 Help Now