Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Disassemble Linq query

Disassemble Linq query

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqhelpquestion
18 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Eslam Afifi

    I'm not sure if this would work. In reflector, View -> Options -> Disassembler -> Optimization = .Net 3.5

    Eslam Afifi

    D Offline
    D Offline
    duncanmhor
    wrote on last edited by
    #5

    Thanks Eslam, but I already had that configuration

    "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

    E 1 Reply Last reply
    0
    • D duncanmhor

      Thanks for that Jon, much appreciated. Unfortunately though, it doesn't work.

      return (from h__TransparentIdentifier1b in from b in context.brands
      join p in context.products on b.brand_id equals p.brand_ID //into p
      join pi in context.product_items on p.product_id equals pi.product_id
      select new { h__TransparentIdentifier1a = h__TransparentIdentifier1a, pi = pi }
      orderby h__TransparentIdentifier1b.pi.display_order
      select h__TransparentIdentifier1b into h__TransparentIdentifier1b
      join i in context.image_product_item_links on h__TransparentIdentifier1b.pi.product_item_id equals i.product_item_id //into i
      join ac in context.attribute_colors on <>h__TransparentIdentifier1b.pi.color_attribute_id equals ac.attribute_color_id //into ac
      where ((<>h__TransparentIdentifier1b.<>h__TransparentIdentifier1a.b.brand_id.Equals(brand_id) && (i.product_item_id == h__TransparentIdentifier1b.pi.product_item_id)) && h__TransparentIdentifier1b.h__TransparentIdentifier1a.p.is_live) && h__TransparentIdentifier1b.pi.is_live
      select ac).ToList().Distinct().ToList();

      Gives the error "cannot resolve symbol h__TransparentIdentifier1a" on the second reference to it (line four of the posted code)

      "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

      E Offline
      E Offline
      Eslam Afifi
      wrote on last edited by
      #6

      Remove all the <> because neither < and > are a valid initial character of a C# identifier.

      Eslam Afifi

      1 Reply Last reply
      0
      • D duncanmhor

        Thanks Eslam, but I already had that configuration

        "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

        E Offline
        E Offline
        Eslam Afifi
        wrote on last edited by
        #7

        I've just noticed that it already gave you a LINQ query.

        Eslam Afifi

        1 Reply Last reply
        0
        • D duncanmhor

          Thanks for that Jon, much appreciated. Unfortunately though, it doesn't work.

          return (from h__TransparentIdentifier1b in from b in context.brands
          join p in context.products on b.brand_id equals p.brand_ID //into p
          join pi in context.product_items on p.product_id equals pi.product_id
          select new { h__TransparentIdentifier1a = h__TransparentIdentifier1a, pi = pi }
          orderby h__TransparentIdentifier1b.pi.display_order
          select h__TransparentIdentifier1b into h__TransparentIdentifier1b
          join i in context.image_product_item_links on h__TransparentIdentifier1b.pi.product_item_id equals i.product_item_id //into i
          join ac in context.attribute_colors on <>h__TransparentIdentifier1b.pi.color_attribute_id equals ac.attribute_color_id //into ac
          where ((<>h__TransparentIdentifier1b.<>h__TransparentIdentifier1a.b.brand_id.Equals(brand_id) && (i.product_item_id == h__TransparentIdentifier1b.pi.product_item_id)) && h__TransparentIdentifier1b.h__TransparentIdentifier1a.p.is_live) && h__TransparentIdentifier1b.pi.is_live
          select ac).ToList().Distinct().ToList();

          Gives the error "cannot resolve symbol h__TransparentIdentifier1a" on the second reference to it (line four of the posted code)

          "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

          J Offline
          J Offline
          Jon Rista
          wrote on last edited by
          #8

          Thats because it starts with <>. You gotta remove all of the <> at the beginning of any identifier..dotted or not: <>h__TransparentIdentifier1b.<>h__TransparentIdentifier1a.b.brand_id.Equals(brand_id) should be: h__TransparentIdentifier1b.h__TransparentIdentifier1a.b.brand_id.Equals(brand_id)

          D 1 Reply Last reply
          0
          • J Jon Rista

            Thats because it starts with <>. You gotta remove all of the <> at the beginning of any identifier..dotted or not: <>h__TransparentIdentifier1b.<>h__TransparentIdentifier1a.b.brand_id.Equals(brand_id) should be: h__TransparentIdentifier1b.h__TransparentIdentifier1a.b.brand_id.Equals(brand_id)

            D Offline
            D Offline
            duncanmhor
            wrote on last edited by
            #9

            I'm sorry, I should have made it clear that I have removed all angle brackets from the code, but the error remains.

            "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

            E 1 Reply Last reply
            0
            • D duncanmhor

              I'm sorry, I should have made it clear that I have removed all angle brackets from the code, but the error remains.

              "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

              E Offline
              E Offline
              Eslam Afifi
              wrote on last edited by
              #10

              What does the error say?

              Eslam Afifi

              D 1 Reply Last reply
              0
              • E Eslam Afifi

                What does the error say?

                Eslam Afifi

                D Offline
                D Offline
                duncanmhor
                wrote on last edited by
                #11

                "cannot resolve symbol h__TransparentIdentifier1a"

                "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

                J E 2 Replies Last reply
                0
                • D duncanmhor

                  Hi All, I have been tasked with recovering some source code from compiled assemblies (all legit, the work was done in-house but the code has gone missing). I've been using reflector, and have disassembled the assemblies. My current issue is that there is a considerable number of linq queries going on, and reflector, excellent tool though it is, seems to have trouble with them. I'm getting output like this:

                  return (from <>h__TransparentIdentifier1b in from b in context.brands
                  join p in context.products on b.brand_id equals p.brand_ID \\into p
                  join pi in context.product_items on p.product_id equals pi.product_id
                  select new { <>h__TransparentIdentifier1a = <>h__TransparentIdentifier1a, pi = pi }
                  orderby <>h__TransparentIdentifier1b.pi.display_order
                  select <>h__TransparentIdentifier1b into <>h__TransparentIdentifier1b
                  join i in context.image_product_item_links on <>h__TransparentIdentifier1b.pi.product_item_id equals i.product_item_id into i
                  join ac in context.attribute_colors on <>h__TransparentIdentifier1b.pi.color_attribute_id equals ac.attribute_color_id into ac
                  where ((<>h__TransparentIdentifier1b.<>h__TransparentIdentifier1a.b.brand_id.Equals(brand_id) && (i.product_item_id == <>h__TransparentIdentifier1b.pi.product_item_id)) && <>h__TransparentIdentifier1b.<>h__TransparentIdentifier1a.p.is_live) && <>h__TransparentIdentifier1b.pi.is_live
                  select ac)

                  Can anyone give me any hints as to how I would go about reconstituting the original query? Thanks in advance

                  "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

                  J Offline
                  J Offline
                  Judah Gabriel Himango
                  wrote on last edited by
                  #12

                  2 things: 1. You'll need to remove all the angle brackets in order for it to compile with a C# compiler. 2. Any compiler-generated classes referenced in this query will need to have their names fixed so that they'll compile in a C# compiler as well. The compiler usually generates classes when you capture local variables in an anonymous method, and also when you use a yield return iterator. If you have these things, technically it *should* compile. I've seen bugs in Reflector, though, where it doesn't generate valid C# code.

                  Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango

                  J 1 Reply Last reply
                  0
                  • J Judah Gabriel Himango

                    2 things: 1. You'll need to remove all the angle brackets in order for it to compile with a C# compiler. 2. Any compiler-generated classes referenced in this query will need to have their names fixed so that they'll compile in a C# compiler as well. The compiler usually generates classes when you capture local variables in an anonymous method, and also when you use a yield return iterator. If you have these things, technically it *should* compile. I've seen bugs in Reflector, though, where it doesn't generate valid C# code.

                    Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango

                    J Offline
                    J Offline
                    Jon Rista
                    wrote on last edited by
                    #13

                    Judah Himango wrote:

                    I've seen bugs in Reflector, though, where it doesn't generate valid C# code.

                    They arn't bugs, it is generating the internal intermediate notation the C# compiler generates when it translates syntactic sugar into something it will compile internally. For example, the fault{} block of a try/catch/fault/finally, is only supported internally by the C# compiler, not in normal code use. The notation where types, functions, and identifiers start with <> is also an internal notation, and is technically valid, just not in normal use. You can see the same identifiers when you use ILDasm.

                    J 1 Reply Last reply
                    0
                    • D duncanmhor

                      "cannot resolve symbol h__TransparentIdentifier1a"

                      "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

                      J Offline
                      J Offline
                      Jon Rista
                      wrote on last edited by
                      #14

                      Is there any way you can post the full function from reflector? It seems that h__TransparentIdentifier1a is actually a variable or field or something, beyond the scope of the LINQ query, as is evident here: select new { <>h__TransparentIdentifier1a = <>h__TransparentIdentifier1a, pi = pi } This creates a new anonymous type who's first property is a reference to some variable called <>h__TransparentIdentifier1a that is not within the scope of the LINQ query...so if it compiled at all, then that identifier must exist somewhere other than the LINQ query.

                      1 Reply Last reply
                      0
                      • D duncanmhor

                        "cannot resolve symbol h__TransparentIdentifier1a"

                        "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

                        E Offline
                        E Offline
                        Eslam Afifi
                        wrote on last edited by
                        #15

                        Ok, saw it. The eror is because the second h__TransparentIdentifier1a in that line (line 4) is refereing to something defined outside that query. See the code in reflector again. You'll probably see it defined above that query or somewhere else in that class. That's all I can tell. [Edit]I had to step away from the computer for a while and I didn't know that someone already answered that.[/Edit]

                        Eslam Afifi

                        D 1 Reply Last reply
                        0
                        • E Eslam Afifi

                          Ok, saw it. The eror is because the second h__TransparentIdentifier1a in that line (line 4) is refereing to something defined outside that query. See the code in reflector again. You'll probably see it defined above that query or somewhere else in that class. That's all I can tell. [Edit]I had to step away from the computer for a while and I didn't know that someone already answered that.[/Edit]

                          Eslam Afifi

                          D Offline
                          D Offline
                          duncanmhor
                          wrote on last edited by
                          #16

                          Thanks to you both, I'll give this a try on Monday. Have a good weekend

                          "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

                          1 Reply Last reply
                          0
                          • J Jon Rista

                            Judah Himango wrote:

                            I've seen bugs in Reflector, though, where it doesn't generate valid C# code.

                            They arn't bugs, it is generating the internal intermediate notation the C# compiler generates when it translates syntactic sugar into something it will compile internally. For example, the fault{} block of a try/catch/fault/finally, is only supported internally by the C# compiler, not in normal code use. The notation where types, functions, and identifiers start with <> is also an internal notation, and is technically valid, just not in normal use. You can see the same identifiers when you use ILDasm.

                            J Offline
                            J Offline
                            Judah Gabriel Himango
                            wrote on last edited by
                            #17

                            Is that right? You learn something new everyday. Thanks.

                            Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango

                            J 1 Reply Last reply
                            0
                            • J Judah Gabriel Himango

                              Is that right? You learn something new everyday. Thanks.

                              Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango

                              J Offline
                              J Offline
                              Jon Rista
                              wrote on last edited by
                              #18

                              Actually, I made a small mistake in my previous comment. What the C# compiler translates your code to isn't specific to itself...its specific to IL. For example, IL supports the fault block in a try/catch statement, but normal C# code does not. Reflector doesn't really have an option when it encounters a fault in IL...so it puts a fault {} block in the C# code it generates.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups