Same query of the context - regular and reflection - one succeeds, the other fails. Why? RRS feed

  • Question

  • This time it's a puzzling one:

    Here is code basically doing the same thing, one through Reflection and one through normal code (Thema is a custom entity and EntType is a generic type. I am using the Data Service):

    var lst = zenContext.GetType().GetProperty(resourceType.Name).GetValue(DataLoader.zenContext, null) as IEnumerable<EntType>; var existingZentityObj = (from zoResInst in lst where (zenContext.LoadProperty(zoResInst,"Title").ToString())

    .Equals (entTitle, StringComparison.OrdinalIgnoreCase) select zoResInst).FirstOrDefault(); var testObj = (from thm in zenContext.Thema where thm.Title.Equals(entTitle, StringComparison.OrdinalIgnoreCase) select thm).FirstOrDefault();

    The first (existingZentityObj) is null, while the second (testObj) is assigned the correct value (finds a duplicate entity). I have checked that lst above points to the correct collection of objects. Even if I cast it as System.Data.Services.Client.DataServiceQuery<EntType>, then the exception The expression (value(UnityDataImport.ZenDataService.ZentityContext).LoadProperty([10007], "Title").ToString() == "Start Here") is not supported ("Start Here" is simply the value to be compared against. Any ideas? Is this even supported? I believe it is, but when using the DataService it's more difficult, because none of the custom Resources are defined as of base type Resource! Looking forward to your response.



    Thursday, April 19, 2012 11:35 AM

All replies

  • Hi Wiz,

    Sorry,for responding you bit late.

    I have been working on this and will get back to you with updates.


    Tuesday, April 24, 2012 4:04 AM
  • Wiz, I could not reproduce the same at my end. The first query a bit complex to me. Can you please put the same example query in terms of USPresident. It would be a lot easier to me to analyze then. What is resourcetype.Name?

    Sorry for giving an extra trouble.


    Thursday, April 26, 2012 5:29 AM