Created
June 7, 2012 11:19
-
-
Save tugberkugurlu/2888280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> Query<T>(this DbContext @this, System.Linq.Expressions.Expression<Func<T, bool>> predicate = null) | |
where T : class { | |
var query = (predicate != null) ? @this.Set<T>().Where(predicate) : @this.Set<T>(); | |
var cmd = new SqlCommand(); | |
cmd.Connection = (SqlConnection)(@this.Database.Connection); | |
//gets the generated t-sql | |
cmd.CommandText = query.ToString(); | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment