簡體   English   中英

當查詢包含聲明的變量時,為什么在SQL Server Profiler中看不到來自實體框架的SQL查詢?

[英]Why is the SQL query from Entity Framework not visible in the Sql Server Profiler when query contains declared variables?

代碼段:

        using (var dc = new Database())
        {
            var results = from a in dc.Article
                          where a.IdNeswpaper == 12
                          select new
                          {
                              a.Id,                               
                          };
            dataGrid1.ItemsSource = results;
        }

此查詢在Sql Profiler中可見,但這是:

        int idNews = 12;
        using (var dc = new Database())
        {
            var results = from a in dc.Article
                          where a.IdNeswpaper == idNews
                          select new
                          {
                              a.Id,                               
                          };
            dataGrid1.ItemsSource = results;
        }

不可見,兩者均正確完成並顯示數據。 為什么第二個查詢在Sql Profiler中不可見? 有任何想法嗎?

我不想告訴你,但你必須看起來更好。 查詢在那里。 也許您將其過濾掉了?

重點是-如果沒有提交SQL文本,就無法通過連接將數據拉出數據庫。 沒有。 因此,要獲取數據,查詢必須存在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM