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