I created an EDMX object from the database with which I am programming.
I need to get input from a user and save it in a row in a database table. The problem is that I need to limit the length of the input lines to the width of the corresponding VARCHAR column in the database.
When I look at the model, I can clearly see in the properties window that the model knows the maximum length of the string, but I do not know how to access this data in the code.
If I want to write something like this:
Entities entities = new Entities();
myTable = entities.myTable.First();
if (userInput.length > myTable.columnA.MaxLength)
{
}
else
{
myTable.columnA = userInput;
}
How do i write?
Update: I would like to indicate that the IObjectContextAdapaterone mentioned in the answers below is in the namespace System.Data.Entity.Infrastructure.