none
why the output always “System.Object” RRS feed

  • Question

  • in EF I want tto get the first value of query so I use 
      ExecuteStoreQuery<object>(Query, null).FirstOrDefault();
    because I don't know what's the actual returned data type 
    if the value comming is numeric is crash , so I used the following

      ExecuteStoreQuery<object>(Query, null).Select(x => x.ToString()).FirstOrDefault() 
    but the resulted string  always `System.Object` 

    any idea how to get the actual value 

    Best regards
    Wednesday, October 17, 2012 6:01 PM

All replies

  • Hi;

    If you are returning a string then it should be the following.

    ExecuteStoreQuery<String>(Query, null).Select(x => x.ToString()).FirstOrDefault();

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, October 17, 2012 10:40 PM
  • Hi,

    ExecuteStoreQuery is supposed to execute the query and return entities containing the data returned. So normally you would have a class that you wanted to populate from the results and that is what you would enter in the angle brackets.

    So I'm not sure what you are trying to achieve here. Could you provide some more information about what type of query you are trying to execute, and what you expect to return.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Thursday, October 18, 2012 5:23 PM
    Moderator