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
Anthony Tan
NA
10
746
Inserting data based on my selected fields only
Oct 21 2019 1:42 AM
Dear Experts,
I am a newbie for ASP.NET and I have a question to seek for your advice.
I am creating a new record in the database & below is the code I am using now in the controller:
public
ActionResult Create(TCustomer customer)
{
if
(ModelState.IsValid)
{
_CustomerRepository.NewCustomer(customer);
_CustomerRepository.Save();
return
RedirectToAction(
"Index"
);
}
return
View();
}
here is the code in my Repo :
public
void
NewCustomer(TCustomer customer)
{
_dbContext.TCustomers.Add(customer);
Save();
}
My question is, how can i save the database on the selected fields only?
For example, I have Customer_name, Customer_phone, customer_dob & customer_age
and I just want to select
Customer_name, Customer_phone
to be inserted into the database. and before I save the customer_name, customer_phone I may need to find turn the data.
Hope you understand what i am saying and advise me.
Many thanks
Ant
Reply
Answers (
3
)
Table Split in .NET MVC to use same model in two views with
how to bind category and their subcategory in treeview