locked
Expand() method erroring for query of an Entity without any Associations defined RRS feed

  • Question

  • Hello,

    When I try to "Expand()" an entity to include its associations, and the entity has no associations, I get the following error:

    Value cannot be null.
    Parameter name: second

    This is only the case for a query that returns a single entity, based on an ID match.  If that entity was recently created in the DB, and does not yet have any associated objects, then I get the error when I try to do an "Expand()".

    For example:

    from role in context.Role.Expand("Activity")
    where role.ID == someRoleID
    select role;

    If the Role does not yet have an associated "Activity", then I get an error.  Strangely, the error does not occur when I do a mass query that retrieves all Roles (including the above one)....

    from role in context.Role.Expand("Activity")
    select role;
    Tuesday, December 16, 2008 6:49 AM

Answers

  • Hi,

       This is now a known issue that we are tracking. It happens to expanded collections if your merge option is OverwriteChanges or PreserveChanges.

     

    Regards,

    PQ


    Peter Q.
    Tuesday, January 27, 2009 7:05 PM
    Answerer

All replies

  • Hi,
     What is the MergeOption when you run this query ?
     You can query the Context.MergeOption property to get this value.
    Phani Raj Astoria
    Tuesday, December 16, 2008 7:04 AM
    Moderator
  • "Value cannot be null.
    Parameter name: second"

    Looks like an exception thrown by the == operator to me. Check that both sides of the equal sign is not null.

    Do you have the stack trace from the exception?
    Peter Q.
    Tuesday, December 16, 2008 7:33 AM
    Answerer
  • I'm having the same issue as the first poster.

    var query = from p in ctx.PatientSet.Expand("PatientInsuranceCompanys")

    where p.PatientId == this.PatientID

    select p;

     

    this.PatiendID has the correct value and I get the same "Value cannot be null.
    Parameter name: second" error when there is not yet a record for PatientInsuranceCompanys

     

    Rusty


     

    Tuesday, January 27, 2009 7:02 PM
  • Hi,

       This is now a known issue that we are tracking. It happens to expanded collections if your merge option is OverwriteChanges or PreserveChanges.

     

    Regards,

    PQ


    Peter Q.
    Tuesday, January 27, 2009 7:05 PM
    Answerer
  • For those building production apps now with Astoria ...

     

    1) What is the recommended work around?

     

    2) What is the expected resolution date?

     

     John Papa

    MVP / Silverlight Insider


    -- John
    Wednesday, January 28, 2009 5:15 PM