考慮這段代碼:爲什麼實體框架中的SQL查詢在分析器中不可見?
var question = context.Questionnaires.FirstOrDefault(q => q.id == 169).Categories.ToList()[1].Questions.ToList()[0];
這僅僅是我得到的EF如何工作的熟悉一些excerise代碼。所以出於這個原因,我創建了幾個表格。參考類別和類別的問卷有對問題的參考。
我在這裏注意到當我執行這段代碼時,我在調查問卷中只看到了調查問卷的select語句。但我想知道,查詢的位置和問題在哪裏?我找不到這個查詢?我認爲這個必須在profiler中可見,對吧?
編輯: 這是我從分析器獲得:
SELECT TOP (1)
[Extent1].[id] AS [id],
[Extent1].[actualFrom] AS [actualFrom],
[Extent1].[name] AS [name],
[Extent1].[version] AS [version],
[Extent1].[startDate] AS [startDate],
[Extent1].[endDate] AS [endDate],
[Extent1].[description] AS [description],
[Extent1].[createdOn] AS [createdOn],
[Extent1].[createdBy] AS [createdBy],
[Extent1].[showQuestionCode] AS [showQuestionCode],
[Extent1].[font] AS [font],
[Extent1].[removed] AS [removed],
[Extent1].[showAchievementsAppointmentTab] AS [showAchievementsAppointmentTab],
[Extent1].[showConceptTabs] AS [showConceptTabs],
[Extent1].[f_QuestionnaireBuilder_QuestionnaireType_Id] AS [f_QuestionnaireBuilder_QuestionnaireType_Id],
[Extent1].[f_QuestionnaireBuilder_Status_Id] AS [f_QuestionnaireBuilder_Status_Id],
[Extent1].[f_QuestionnaireBuilder_Questionnaire_ParentId] AS [f_QuestionnaireBuilder_Questionnaire_ParentId],
[Extent1].[f_QuestionnaireBuilder_QuestionnaireCategory_Id] AS [f_QuestionnaireBuilder_QuestionnaireCategory_Id],
[Extent1].[f_Careplan_VisionModel] AS [f_Careplan_VisionModel]
FROM [implementation].[QuestionnaireBuilder_Questionnaire] AS [Extent1]
WHERE 169 = [Extent1].[id]
你可以顯示你能用探查器嗅探的SELECT嗎? –
我修改了我的帖子 – Martijn
將分析器擱置一會兒,這段代碼是否會返回預期結果? –