tags:

views:

30

answers:

0

I am using LINQ to SQL and I would like to set the default value of a filed called UserName to be the logged in user name.

So I can do the following, which works

partial void OnCreated() { this.UserName = Thread.CurrentPrincipal.Identity.Name; }

However I'm not happy about using the Thread.CurrentPrincipal.Identity.Name within my Domain Models as this should be handled by the User Interface.

What I would like is when I create the LINQ to SQL object I have to pass in the UserName as a parameter, such as this, but this does not work as you would expect.

partial void OnCreated(string userName) { this.UserName = userName; }

Any ideas on working around this?