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
NeCroFire
NA
86
0
Entity Framework with conditional default values
Nov 8 2010 3:20 AM
Hi
We are having some problems with default values in EF.
In every table we have these 4 columns:
DateCreated
DateUpdated
UserCreated
UserUpdated
When you insert a new record all 4 fields need to get a value, but when you update a record only the 2 update fields needs new values.
We can set these fields in code every time, but we would like it to be more automatic. The biggest obstacle is when you add a child object to a parent object.
Example:
ContactNumber _Number = new ContactNumber();
_Number.Number = 0826224710;
_Number.Type = "Home";
Client.ContactNumber.Add(_Number);
If you don't specify any values for the date fields, you get a date out of range error from SQL.
What we would like to do is set the User Details at login and have the entity model set the values to those 4 fields when ever a record is either added or updated without us having to set it "by hand" every time. This code should also be un-effected when updating the model from the DB.
I hope this makes sens and that someone can help.
Thanks in advance :)
Reply
Answers (
0
)
Remove a string in string
Problemas spliContainer