when we use linq to sql then few visualizer exist which show us what sql is generating by linq but when we query object by linq then is there any way out to have similar sql statement. as exmple
string[] names =
new string[] { "Jon Skeet", "Marc Gravell", "tvanfosson",
"cletus", "Greg Hewgill", "JaredPar" };
var results = from name in names
where name.StartsWith("J")
select name;
can we extract sql from result?
a person advise to use this below function to have sql....
public static class MyExtensions
{
public static string ToTraceString<T>(this IQueryable<T> t)
{
string sql = "";
ObjectQuery<T> oqt = t as ObjectQuery<T>;
if (oqt != null)
sql = oqt.ToTraceString();
return sql;
}
}
is it true? if yes can u tell me how to convert my result to IQueryable and then call ToTraceString() method. thanks