views:

99

answers:

0

I have a LINQ-to-SQL class called Task.

I also have a partial class called Task which adds methods to its functionality:

public partial class Task : Item
{...

However, now I want to execute code when a Task object is constructed but if I had a constructor:

public Task()
{
    ...
}

it tells me:

'TestApp.Models.Task' already defines a member called 'Task' with the same parameter types.

Is there any way I can add code to the parameterless constructor that exists while keeping this code external so it is not deleted when I regenerate the LINQ-to-SQL class?

Or do I have to e.g. create a static method called CreateInstance(), create the object, then alter it externally? Or create a constructor with a fake parameter so I can define it myself? I would assume there is a cleaner way to do this.