Intermittent problem: Entity 'Legacy.Staff' has a property 'StaffOfficeReference' with an unsupported type. Lazy load the issue? RRS feed

  • Question

  • Hi All,

    Loving the experience of developing with LightSwitch, but I'm having an intermittent issue when traversing a relationship that points across datasources.  The exception being thrown is an unsupported type exception.  The underlying content is the same between error and non-error runs, so the issue doesn't appear be to caused by the actual data.  

    The exception is thrown in a generated module (EntityG03.cs) when a computed property is evaluated.  The computed property's mission in life is to traverse a relationship across datasources to grab display information for binding in the UI. 

    The relationship in question is between a table in a external sql server 2008R2 database and a RIA service.  The RIA Service was built against an EF model that consisted of views that have had their referential constraints defined explicitly in the model.  I've simplified the model down to three levels:

     LegacyStaffOffice 0..1 ->* LegacyStaff 1-->* LegacyStaffAssignment

    (i.e. not all staff have an office, but if they do, they can have only one and all staff can have multiple assignments)

    The property evaluation in LS isn't complex:

    partial void FullName_Compute(ref string result)
            if (this.LegacyStaff != null)
                result = this.LegacyStaff.DisplayName;

    The exception stack is:

    Microsoft.LightSwitch.DataServiceOperationException was unhandled by user code
      Message=Entity 'legacyConnnector.LegacyStaff' has a property 'LegacyStaffOfficeReference' with an unsupported type.
           at System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddEntityType(Type entityType)
           at System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddQueryMethod(DomainOperationEntry method)
           at System.ServiceModel.DomainServices.Server.DomainServiceDescription.Initialize()
           at System.ServiceModel.DomainServices.Server.DomainServiceDescription.CreateDescription(Type domainServiceType)
           at System.ServiceModel.DomainServices.Server.DomainServiceDescription.<>c__DisplayClass10.<GetDescription>b__f(Type type)
           at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
           at System.ServiceModel.DomainServices.Server.DomainServiceDescription.GetDescription(Type domainServiceType)
           at System.ServiceModel.DomainServices.Server.DomainService.get_ServiceDescription()

    So, it appears that the gag point is because *sometimes* the LegacyStaffOffices haven't been filled, and sometimes they have.  I haven't been able to find any pattern yet as to why this happens.

    SQLProfiler shows a call to get the offices from db is made when it succeeds, but a call is not made when it fails.  There are other smaller discrepancies in the ordering of calls to the db.  I would have thought that would be deterministic. (Other oddities in the trace (select top(0) from.. wtf?), that probably aren't relevant to the issue, but still leave one scratching their head.)

    So my question is, is there a declarative way to to set the ordering of access to the tables?  I would have thought it would be inferred from the relationship defined in the EF model...




    Wednesday, July 31, 2013 7:47 PM

All replies