Skip to content

Instantly share code, notes, and snippets.

@vendettamit
Last active February 12, 2016 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vendettamit/d1ca4d501d4a43423bd9 to your computer and use it in GitHub Desktop.
Save vendettamit/d1ca4d501d4a43423bd9 to your computer and use it in GitHub Desktop.
var context = new ConferenceDb();
var query = context.Set<Conference>().AsNoTracking();
var predicate = ExpressionBuilder.MakePredicate<Conference>(new List<ExpressionModel>(new[] {
new ExpressionModel() {
Operator = ExpressionBuilder.ExpressionOperators.Equals,
PropertyName = "Slug",
Value = "Test"
},
new ExpressionModel() {
Operator = ExpressionBuilder.ExpressionOperators.StartsWith,
PropertyName = "Name",
Value = "Amit"
},
new ExpressionModel() {
Operator = ExpressionBuilder.ExpressionOperators.Contains,
PropertyName = "Location",
Value = "NY"
}
}));
var result = query.Where(predicate);
============= output =============
{SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Slug] AS [Slug],
[Extent1].[Name] AS [Name],
[Extent1].[Location] AS [Location],
[Extent1].[AccessCode] AS [AccessCode],
[Extent1].[OwnerName] AS [OwnerName],
[Extent1].[OwnerEmail] AS [OwnerEmail],
[Extent1].[WasEverPublished] AS [WasEverPublished],
[Extent1].[Description] AS [Description],
[Extent1].[Tagline] AS [Tagline],
[Extent1].[TwitterSearch] AS [TwitterSearch],
[Extent1].[StartDate] AS [StartDate],
[Extent1].[EndDate] AS [EndDate],
[Extent1].[IsPublished] AS [IsPublished]
FROM [ConferenceManagement].[Conferences] AS [Extent1]
WHERE (N'Test' = [Extent1].[Slug]) AND ([Extent1].[Name] LIKE N'Amit%') AND ([Extent1].[Location] LIKE N'%NY%')}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment