Skip to content

Instantly share code, notes, and snippets.

@julielerman
Last active November 4, 2016 13:54
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 julielerman/99fc47ed572bf0b2f9c276b5b3b25937 to your computer and use it in GitHub Desktop.
Save julielerman/99fc47ed572bf0b2f9c276b5b3b25937 to your computer and use it in GitHub Desktop.
EF Core 1.1 Preview Logs for Single & First Comparisons
**TEST #1: First() ****
Assert.IsInstanceOfType(_context.Samurais.First(s => s.Id == 1),typeof(Samurai));
COMPILING QUERY MODEL:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.First()'
Optimized query model:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.First()'
(QueryContext queryContext) => IEnumerable<Samurai> _ToSequence(
element: Samurai First(
source: IEnumerable<Samurai> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [s].[Id], [s].[Name]
FROM [Samurais] AS [s]
WHERE [s].[Id] = 1
,
shaper: UnbufferedEntityShaper<Samurai>
)
)
)
Opening connection to database 'SamuraiData' on server '(localdb)\mssqllocaldb'.
Executed DbCommand (7ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [s].[Id], [s].[Name]
FROM [Samurais] AS [s]
WHERE [s].[Id] = 1
Closing connection to database 'SamuraiData' on server '(localdb)\mssqllocaldb'.
*******************************************************
**TEST #2: Single() **
Assert.IsInstanceOfType(_context.Samurais.Single(s => s.Id == 1),typeof(Samurai));
COMPILING QUERY MODEL:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.Single()'
Compiling query model:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.Single()'
Optimized query model:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.Single()'
Optimized query model:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.Single()'
(QueryContext queryContext) => IEnumerable<Samurai> _ToSequence(
element: Samurai Single(
source: IEnumerable<Samurai> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(2) [s].[Id], [s].[Name]
FROM [Samurais] AS [s]
WHERE [s].[Id] = 1
,
shaper: UnbufferedEntityShaper<Samurai>
)
)
)
TRACKED: True
(QueryContext queryContext) => IEnumerable<Samurai> _ToSequence(
element: Samurai Single(
source: IEnumerable<Samurai> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(2) [s].[Id], [s].[Name]
FROM [Samurais] AS [s]
WHERE [s].[Id] = 1
,
shaper: UnbufferedEntityShaper<Samurai>
)
)
)
Opening connection to database 'SamuraiData' on server '(localdb)\mssqllocaldb'.
Opening connection to database 'SamuraiData' on server '(localdb)\mssqllocaldb'.
Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(2) [s].[Id], [s].[Name]
FROM [Samurais] AS [s]
WHERE [s].[Id] = 1
Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(2) [s].[Id], [s].[Name]
FROM [Samurais] AS [s]
WHERE [s].[Id] = 1
Closing connection to database 'SamuraiData' on server '(localdb)\mssqllocaldb'.
Closing connection to database 'SamuraiData' on server '(localdb)\mssqllocaldb'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment