I have generated LinQ to SQL entity classes using the generator in Visual Studio 2010.
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Address")]
public partial class Address : INotifyPropertyChanging,INotifyPropertyChanged
{
//all the generated methods are here
}
Then I create an Interface ITask
public Interface ITask
{
//some interface methods go here
}
Finally I create my class
class myclass : Address, ITask
{
//implement interface methods
}
Elsewhere in my unit tests I create a myclass object the following happens
myclass temp=new myclass();
Address adr=(Address)temp;
adr.GetType();//returns myclass when I watch the var in debugger
DataContext dc=new DataContext();//the linq data context
dc.Addresses.InsertOnSubmit(adr);//Object reference not set
//to an instance of an object NullReferenceException
ITask task=(ITask)temp;
temp.Callinterfacemethods();//works fine, iam able to call interface methods
I am a C++ programmer, this is part of my first C# assignment. What am I doing wrong? The above would be perfectly valid in C++.
Thanks.
David