Tracer les requêtes SQL d’Entity Framework

Lors des développements avec Entity Framework, il nous arrive fréquemment de vouloir déterminer ce que LINQ va envoyer au serveur de base de données. La méthode d’extension suivante permet d’obtenir la requête SQL associée à la requête LINQ.

public static class LinqExtensions
    public static string ToTraceString<T>(this IQueryable<T> t)
        ObjectQuery<T> oqt = t as ObjectQuery<T>;

        if (oqt != null)
            return oqt.ToTraceString();

        return string.Empty;

Tagged with: ,
Posted in Tips and others

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow me
   RSS Feed    Twitter    Linked In

Write you email address to subscribe at this blog and to receive new posts by mail.

Join 611 other followers

Who I am?

%d bloggers like this: