I have recently been looking into LINQ and wanted to know more about it and was searching for a simple method of visualizing my queries to get a bit more detail on what is going on during the query.
Does anyone know of any tools that are openly available to acc开发者_如何学Complish something like this?
Thanks,
Josh
You might want to take at this article on Visual LINQ at Jon Skeet's blog. Visual LINQ is a tool that will allow you to visually watch your LINQ query in action.
You can directly download the files for it here.
Hope this helps.
Edit: Scott Gu's blog also has an article on the LINQ to SQL Debug Visualizer, which might help you out.
That depends on what sort of LINQ you're talking about. If you're referring to LINQ-to-Objects, then WYSIWYG; with the exception of some methods that get optimized for certain standard framework libraries (e.g. the Count()
extension method on IEnumerable
is smart enough to call the Count
property if the target enumerable implements ICollection
), there's no real optimization that's done on a case-by-case basis.
For something like LINQ-to-SQL, you'll have to use a database-specific monitoring tool, like SQL Server Profiler for MS SQL Server.
You can also use SQL Profiler in SQL Management Studio (not available in express edition). You can see how SQL server handles the Linq queries.
SQL Server Profiler is probably your best bet. You can watch as queries are executed and have a running log of everything that has happened. It's quite configurable, you can set it to capture only the events you're interested in.
Try this video tutorial: http://sqlserverpedia.com/wiki/Using_SQL_Server_Profiler
A great tool for Linq to SQL queries that I've used many times is the Linq to SQL Profiler. Not only does it show your queries, but it also helps you understand how they can be optimized to avoid pitfalls such as N+1.
精彩评论