Unbelievable duplicate in an Entity Framework Query

前端 未结 5 599
情书的邮戳
情书的邮戳 2021-02-07 11:40

My SQL query against a particular view returns me 3 different rows.

 select * from vwSummary
 where vidate >= \'10-15-2010\' and vidate <= \'10-15-2010\'
          


        
5条回答
  •  青春惊慌失措
    2021-02-07 12:22

    Entity Framework exposes a number of performance tuning options to help you optimise the performance of your applications. One of these tuning options is .AsNoTracking(). This optimisation allows you to tell Entity Framework not to track the results of a query. This means that Entity Framework performs no additional processing or storage of the entities which are returned by the query. However it also means that you cant update these entities without reattaching them to the tracking graph.

    You can set AsNoTracking option directly on your view to resolve this issue.

    context.viewname.AsNoTracking().Where(x => x.ColumnName != null);

提交回复
热议问题