Association null after WCF call

Jan 7, 2010 at 1:39 AM
Edited Jan 7, 2010 at 1:40 AM

I'm using the Linq to SQL generator, and after making a WCF call, the association properties on my object are null and throwing a null reference exception in their setters. This is one such property:


[DataMember(Order = 4, EmitDefaultValue = false)]
[Association(Name = "Family_FamilyConfiguration", Storage = "familyConfigurations", ThisKey = "FamilyID", OtherKey = "FamilyID")]
public EntitySet<FamilyConfiguration> FamilyConfigurations
           if (this.serializing && !this.familyConfigurations.HasLoadedOrAssignedValues)
               return null;
           return this.familyConfigurations; 
          this.familyConfigurations.Assign(value); // EXCEPTION: familyConfigurations is null


Prior to the call, the object is fully formed and correct, familyConfigurations included. I even ran it through a DataContractSerializer and confirmed that the object is properly serialized with the correct data, so I don't believe this is a serialization error, unless I'm missing something. I put a breakpoint in the class's constructor, on the line that initializes familyConfigurations, but it wasn't hit for some reason. All I've done is run the Linq to SQL generator (as is, not modified) against my tables, setting serialization to unidirectional. Have I done something wrong?

Jan 15, 2010 at 10:49 PM


Jan 25, 2010 at 1:32 PM

Does the problem exist with code generated by the LINQ to SQL generator built into Visual Studio?

Jan 25, 2010 at 1:38 PM


Jan 26, 2010 at 12:21 PM

Ok. Any idea what the difference is between code generated by MSLinqToSqlGenerator and T4 Toolbox?

Jan 26, 2010 at 2:10 PM

Nope. I compared the two, and they looked pretty similar. I went with another code generator, so I'm afraid I no longer have the code to compare it further.