简体   繁体   中英

Why is LINQ expression causing two separate queries on the DB?

I have the following LINQ expression:

var rawData = ( from e in _man.Details
where e.Id == "G00"
select e).ToList();

which when I run with Profiler open I can see causes two separate identical queries. What is the reason for this and how can this be prevented?

Can you check what is the value in EventClass column in profiler. It probably is SQL:Batch Starting and SQL:Batch Completing (or something similar). Which does not mean 2 queries, but the start and end of execution of one query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM