TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rohan Laghate
NA
79
8.1k
Saving data in database using View Model
Mar 27 2017 1:19 PM
Hi,
Consider a scenario wherein I have 2 domain models say Customers and Orders and then there is a View Model CustomerOrderViewModel.
Now, I have a CreateOrder() method that accepts CustomerOrderViewModel as input parameter.
eg:-
[HttpPost]
public ActionResult CreateOrder(CustomerOrderViewModel input)
{
//code to save
};
Question:- How do I save the data to these 2 domain entities from the view model? ie. the input parameter above will have the data of customers as well as orders however, I want to save the data related to Customers in the customers table where as the data related to Orders in orders table. How can I achieve this?
Thanks!
Reply
Answers (
3
)
Not able to read the dropdownlist selected item in c#
Queried data from Controller to Partial View