Unable to typecast to LinQ Entity base class
<p>I have generated LinQ to SQL entity classes using the generator in Visual Studio 2010.</p>

<pre><code>[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Address")]
    public partial class Address : INotifyPropertyChanging,INotifyPropertyChanged     
   { 
        //all the generated methods are here
   }
</code></pre>

<p>Then I create an Interface  ITask</p>

<pre><code>  public Interface ITask
  {
      //some interface methods go here
  }
</code></pre>

<p>Finally I create my class</p>

<pre><code>class myclass : Address, ITask
{
    //implement interface methods
}
</code></pre>

<p>Elsewhere in my unit tests
I create a myclass object the following happens</p>

<pre><code>    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
</code></pre>

<p>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++.</p>

<p>Thanks.</p>

<p>David    </p>
