none
Retrieving only selected fields from related entity RRS feed

  • Question

  • Hi

    When retrieving an entity/related entity combination via below query;

    Dim Query = From a In Context.MyEntity Select a.id, a.first_name, a.last_name, a.MyRelatedEntity
    

    Is there a way to specify which fields of the related entity are to be retrieved?

    Thanks

    Regards

    Saturday, July 23, 2011 12:37 AM

Answers

  • Yes, it is possible, however the result will be a flat hierarchy since your only option is to return an anonymous type and not an entity.

    You could try something like this:

    Dim Query = From a In Context.MyEntity Select a.id, a.first_name, a.last_name, a.MyRelatedEntity.Column1, a.MyRelatedEntity.Column2
    

    Hope this helps,


    --Rune
    Sunday, July 24, 2011 11:51 AM

All replies

  • Yes, it is possible, however the result will be a flat hierarchy since your only option is to return an anonymous type and not an entity.

    You could try something like this:

    Dim Query = From a In Context.MyEntity Select a.id, a.first_name, a.last_name, a.MyRelatedEntity.Column1, a.MyRelatedEntity.Column2
    

    Hope this helps,


    --Rune
    Sunday, July 24, 2011 11:51 AM
  • Hi,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 2, 2011 3:55 PM
    Moderator