Trace LINQ when using Joins

[Note after the answer: I really request memory objects and why it ToTraceStringdoesn’t work. I added this to save the reader reading time from reading my long message].

I use the command ToTraceStringwhen trying to check how my LINQ queries look. However, today my request has become a little complicated with participation joinand suddenly, I get this error when I try to track my line:

Unable to pass an object of type 'd__7a`1 [EGSLanguageProviderShared.DTODataType]' to enter 'System.Data.Objects.ObjectQuery'.

My request and subsequent call ToTraceStringlooks like this (note that for this you need to refer to System.Data.Entity). Both objects that I request (langDTs and langInstructionsAVDT) are Entity Framework objects (.Net 3.5) from the same database. My Where clause (== av.InstructionAVKey) uses a simple value collection class, nothing is visible there.

      IEnumerable<DTODataType> dts = 
          (from langDT in langDTs 
          join langIAVDT in langInstructionsAVDTs 
          on langDT.DataTypeKey equals langIAVDT.DataTypeKey 
          where langIAVDT.InstructionAVKey == av.InstructionAVKey 
          select langDT).Distinct();
      var sql = ((System.Data.Objects.ObjectQuery)dts).ToTraceString();

Any ideas on how I could see the LINQ translation of this Join? :: -). I noticed that System.Data.Objects has more types of queries, but I can not get any of them that seem more relevant for this case, to work.

LATER EDIT:

As you recommended, I tried changing IEnumerable to IQueryable, but this led to a compilation error of incompatibility like :: - /.

, Runtime (Unable to cast object of type '<DistinctIterator>d__7a1[EGSLanguageProviderShared.DTODataType]' to type 'System.Linq.IQueryable 1 [EGSLanguageProviderShared.DTODataType] '. `)

: langDTs langInstructionsAVDT:

List<DTOInstructionActiveValueDataType> langInstructionsAVDTs = CurrentLPInstructionManager.GetInstructionsActiveValuesDataTypes((from avKey in langInstructionsAVs select avKey.InstructionAVKey).Distinct().ToArray());

List<DTODataType> langDTs = _LPDataTypeManager.GetDataTypes((from dt in langInstructionsAVDTs orderby dt.DataTypeKey select dt.DataTypeKey).Distinct().ToArray());

, , :: -). DTODataType DTOInstructionActiveValueDataType, , - .

EVEN LATER EDIT

, , , ObjectQuery (Entity Framework):

public global::System.Data.Objects.ObjectQuery<instructions> instructions

, , ( DTC-prefixed, ), ( , , , ).

+5
2

, . ObjectQuery, IQueryable<T>.

, SQL-, SQL . DTO , linq-to-objects T-SQL.

+2

IEnumerable<DTODataType> try IQueryable<DTODataType> var.

, - , IEnumerable ObjectQuery

EDIT

, , langDT langInstructionsAVDT?

+5

All Articles