Posts Tagged ‘string’

How do I view the SQL generated by the entity framework?

var result = from x in appEntities
             where x.id = 32
             select x;

var sql = ((System.Data.Objects.ObjectQuery)result).ToTraceString();

Source: http://stackoverflow.com/questions/1412863/how-do-i-view-the-sql-generated-by-the-entity-framework

I create a extension…

public static class IQueryableExtension
{
     public static String ToTraceSQL(this IQueryable obj) 
     {             
         return ((System.Data.Objects.ObjectQuery)obj).ToTraceString();
     }
}

Using this:

var iQuerableResult = dataBase.BiServico.Take(10);
string myResustSQL = iQuerableResult.ToTraceSQL();

Shazan! =)

hope I have helped!

Advertisements

C# – StringFormat

Posted: February 1, 2012 in c#
Tags: , , ,

Exemplos:

http://blog.stevex.net/string-formatting-in-csharp/
http://www.programadorjr.com.br/?p=29

MSDN:

http://msdn.microsoft.com/en-us/library/0c899ak8.aspx