BUG: DLINQ problem in VS designer

Hi guys,

I know it is too early and many-to-many relationship is not supported but I notoced somethign that could help you.

Preface: I have SQL database with three tables: Customer, Vehicle CustomerVehicle (junction one).

I noticed this when I tried to delete all vehicles from junction table with similar statement


//find appropriate record form VehicleCustomers table and delete it
var vc =
Program.DataContext.VehicleCustomers.Where<VehicleCustomer>(c => c.VehicleID == arg.VehicleID);

Program.DataContext.VehicleCustomers.RemoveAll(vc);

and ... NullReferenceExceptin was thrown... Itook a look at generated code and this is what I saw:


[System.Data.DLinq.Table(Name="VehicleCustomer")]

public partial class VehicleCustomer : System.Data.DLinq.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged {

	[System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [System.Data.DLinq.Association(Name="FK_VehicleCustomer_Vehicle", Storage="_Vehicle", ThisKey="VehicleID", IsParent=true)]
    public Vehicle Vehicle {
      get {
        return this._Vehicle.Entity;
      }
      set {
        if ((this._Vehicle.Entity != value)) {
          this.OnPropertyChanging("Vehicle");
          if ((this._Vehicle.Entity != null)) {
            this._Vehicle.Entity = null;
this._Vehicle.Entity.VehicleCustomers.Remove(this);
} this._Vehicle.Entity = value; if ((value != null)) { value.VehicleCustomers.Add(this); } this.OnPropertyChanged("Vehicle"); } } }
}

First .Entity property is nulled and then Entity's property is used...

Best regards

 




Answer this question

BUG: DLINQ problem in VS designer