I have a table that contains the following structure:
ID
Date (today's date/time)
Payment (user defined)
PreviousBal (referenced from another table prior to update)
LayawayID (link to above record)
I am new to Linq, Entity Framework and C#. I would normally write an SQL update statement to easily take care of all of this in one swoop, but in my work with MVC, I've only seen how to update and add to a table based on ALL fields being user inputs.
So my question would be, how do I set a column in the database to a value that is not user defined?
Also, can Linq and EF even handle pulling a value from another table and setting the column value to the result?
Update To Clarify, this is how I have been creating tables thus far in my application
[HttpPost]
public ActionResult CreateCustomer(Customers Customer)
{
if (ModelState.IsValid)
{
_db.Customers.Add(Customer);
_db.SaveChanges();
return RedirectToAction("Index");
}
return View(Customer);
}
In that case, the user has the ability to add ALL columns in the customer table with the exception of the primary key. My confusion comes in with the case where there are columns in my table that need to be set to existing data rather than user input.