0

I wrote a query like this:

  context.PageGroupLangsInSettings
            .Where(x => x.PageGroupLang.Language.CaltureId == langCaltureId && x.PageGroupLang.PageGroup.Id == pageGroupId)
            .Select(x => new { x.Key, x.Value, Order = 0 })
        .Union(
        context.PageGroupSavedSettingDetails
            .Where(x => x.PageGroupSavedSettings.PageGroupLangs
                .Where(y => y.Language.CaltureId == langCaltureId && y.PageGroup.Id == pageGroupId).Any())
            .Select(x => new { x.Key, x.Value, Order = 1 })
        ).ToList()

and now I want to compare 'key' fields with each other using IEqualityCompare but I don't know how should I do it. Thanks :)

Saeed Hamed
  • 732
  • 2
  • 10
  • 28
  • possible duplicate of [IEqualityComparer for anonymous type](http://stackoverflow.com/questions/1071609/iequalitycomparer-for-anonymous-type) – MarcinJuraszek Jul 08 '13 at 07:52

1 Answers1

0

Properties of an anonymous type can be accessed only within the method that declares it. But if you are passing out of the method, accessing the members may require using reflection or some other workaround. Instead you can try creating a class to hold the projection or use Dictionary.