Dynamic and Serializable queries RRS feed

  • Question

  • Hello, everyone!

    I need to find a way to serialize the result of a query on one of my entities. What I want to do is to have a generic method that receives the entity type and all the information for the dynamic query and executes it. The method will return the result of the query and I will serialize that result into XML or JSON.

    The issue here is that my generic method can return two different things: if I select a number of columns, my method tries to return objects of the proxy class "DbDataRecord" and if I just select all the columns it will return full "materialized" entities. So I need to have different methods for serialization: one for DbDataRecords and other for entities.

    It would be ideal to always return DbDataRecords, as they have metadata for the columns which help me on the serialization. A solution would be to put all the columns in the select sentence, but as I told you, this is a generic method so I don't know which columsn does the entity have.

    Do anyone here know how can I achieve this? Any help would be greatly appreciated!

    In advance, many thanks.

    I hope you are OK.
    Thursday, June 23, 2011 1:16 AM


  • Thanks everyone. In the end, the customer defined that the query would never return all the columns. If there are no columns specified, a default set of columns would be selected so my method will always return the desired DbDataRecord.

    I hope you are OK.
    • Marked as answer by PanchoPonceN Thursday, June 30, 2011 4:41 PM
    Thursday, June 30, 2011 4:41 PM

All replies