You are on page 1of 24

Compiling query model:

'(from Product x in DbSet<Product>


where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Compiling query model:
'(from Product x in DbSet<Product>
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Optimized query model:
'(from Product x in DbSet<Product>
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].
[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime',
shaper: UnbufferedEntityShaper<Product>))),
queryContext: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: queryContext)Opening connection to database 'FeaturesDb' on
server '.'.Opened connection to database 'FeaturesDb' on server '.'.Executing
DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (64ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Compiling query model:
'(from Product x in DbSet<Product>
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Optimized query model:
'(from Product x in DbSet<Product>
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].
[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime',
shaper: UnbufferedEntityShaper<Product>))),
queryContext: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: queryContext)Opening connection to database 'FeaturesDb' on
server '.'.Opened connection to database 'FeaturesDb' on server '.'.Executing
DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (58ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Compiling query model:
'(from Product x in DbSet<Product>
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Optimized query model:
'(from Product x in DbSet<Product>
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].
[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime',
shaper: UnbufferedEntityShaper<Product>))),
queryContext: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: queryContext)Opening connection to database 'FeaturesDb' on
server '.'.Opened connection to database 'FeaturesDb' on server '.'.Executing
DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (71ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (74ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (83ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (93ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Opening connection to database 'FeaturesDb' on server '.'.Opened
connection to database 'FeaturesDb' on server '.'.Beginning transaction with
isolation level 'ReadCommitted'.Executing DbCommand [Parameters=[@p0='?', @p1='?',
@p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?', @p10='?',
@p11='?', @p12='?', @p13='?', @p14='?', @p15='?', @p16='?', @p17='?', @p18='?',
@p19='?'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, @p3, 0),
(@p4, @p5, @p6, @p7, 1),
(@p8, @p9, @p10, @p11, 2),
(@p12, @p13, @p14, @p15, 3),
(@p16, @p17, @p18, @p19, 4)) AS i ([Created], [ProductId], [PurchaseLogId],
[Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [PurchaseLogId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[PurchaseLogId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Failed executing DbCommand (55ms) [Parameters=[@p0='?',
@p1='?', @p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?',
@p10='?', @p11='?', @p12='?', @p13='?', @p14='?', @p15='?', @p16='?', @p17='?',
@p18='?', @p19='?'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, @p3, 0),
(@p4, @p5, @p6, @p7, 1),
(@p8, @p9, @p10, @p11, 2),
(@p12, @p13, @p14, @p15, 3),
(@p16, @p17, @p18, @p19, 4)) AS i ([Created], [ProductId], [PurchaseLogId],
[Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [PurchaseLogId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[PurchaseLogId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Disposing transaction.Closing connection to database
'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on server
'.'.An exception occurred in the database while saving changes for context type
'CoreFeaturesDemo.Data.FeaturesDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating
the entries. See the inner exception for details. --->
System.Data.SqlClient.SqlException: Invalid column name 'PurchaseLogId'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean
breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,
Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,
TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32
timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1
completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at
Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationa
lConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2
parameterValues)
at
Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRel
ationalConnection connection, IReadOnlyDictionary`2 parameterValues)
at
Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelati
onalConnection connection)
--- End of inner exception stack trace ---
at
Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelati
onalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(Tuple`2
parameters)
at
Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[T
State,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at
Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult]
(IExecutionStrategy strategy, TState state, Func`2 operation)
at
Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1
commandBatches, IRelationalConnection connection)
at
Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IReadOnlyList`
1 entries)
at
Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IRea
dOnlyList`1 entriesToSave)
at
Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Bool
ean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean
acceptAllChangesOnSuccess)Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (62ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Opening connection to database 'FeaturesDb' on server '.'.Opened
connection to database 'FeaturesDb' on server '.'.Beginning transaction with
isolation level 'ReadCommitted'.Executing DbCommand [Parameters=[@p0='?', @p1='?',
@p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?', @p10='?',
@p11='?', @p12='?', @p13='?', @p14='?'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Executed DbCommand (54ms) [Parameters=[@p0='?', @p1='?',
@p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?', @p10='?',
@p11='?', @p12='?', @p13='?', @p14='?'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];A data reader was disposed.Committing transaction.Closing
connection to database 'FeaturesDb' on server '.'.Closed connection to database
'FeaturesDb' on server '.'.Disposing transaction.Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (66ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Opening connection to database 'FeaturesDb' on server '.'.Opened
connection to database 'FeaturesDb' on server '.'.Beginning transaction with
isolation level 'ReadCommitted'.Sensitive data logging is enabled. Log entries and
exception messages may include sensitive application data, this mode should only be
enabled during development.Executing DbCommand [Parameters=[@p0='09/02/2017
10:00:07', @p1='4', @p2='1', @p3='09/02/2017 10:01:07', @p4='4', @p5='2',
@p6='09/02/2017 10:02:07', @p7='4', @p8='3', @p9='09/02/2017 10:03:07', @p10='4',
@p11='4', @p12='09/02/2017 10:04:07', @p13='4', @p14='5'], CommandType='Text',
CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Executed DbCommand (60ms) [Parameters=[@p0='09/02/2017
10:00:07', @p1='4', @p2='1', @p3='09/02/2017 10:01:07', @p4='4', @p5='2',
@p6='09/02/2017 10:02:07', @p7='4', @p8='3', @p9='09/02/2017 10:03:07', @p10='4',
@p11='4', @p12='09/02/2017 10:04:07', @p13='4', @p14='5'], CommandType='Text',
CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];A data reader was disposed.Committing transaction.Closing
connection to database 'FeaturesDb' on server '.'.Closed connection to database
'FeaturesDb' on server '.'.Disposing transaction.Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (70ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Opening connection to database 'FeaturesDb' on server '.'.Opened
connection to database 'FeaturesDb' on server '.'.Beginning transaction with
isolation level 'ReadCommitted'.Executing DbCommand [Parameters=[@p0='?', @p1='?',
@p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?', @p10='?',
@p11='?', @p12='?', @p13='?', @p14='?'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Executed DbCommand (60ms) [Parameters=[@p0='?', @p1='?',
@p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?', @p10='?',
@p11='?', @p12='?', @p13='?', @p14='?'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];A data reader was disposed.Committing transaction.Closing
connection to database 'FeaturesDb' on server '.'.Closed connection to database
'FeaturesDb' on server '.'.Disposing transaction.Compiling query model:
'(from Product x in
(from Product x in DbSet<Product>
select [x]).Include("Category")
where [x].Name == "Optimus Prime"
select [x]).FirstOrDefault()'Including navigation: '[x].Category'Optimized query
model:
'(from Product x in DbSet<Product>
join ProductCategory x.Category in DbSet<ProductCategory>
on Property([x], "CategoryId") equals Property([x.Category], "Id")
where [x].Name == "Optimus Prime"
select Product _Include(
queryContext: queryContext,
entity: [x],
included: new object[]{ [x.Category] },
fixup: (QueryContext queryContext | Product entity | Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)).FirstOrDefault()'(QueryContext queryContext) => IEnumerable<Product>
_InterceptExceptions(
source: IEnumerable<Product> _TrackEntities(
results: IEnumerable<Product> _ToSequence(Product
FirstOrDefault(IEnumerable<Product> _Select(
source: IEnumerable<TransparentIdentifier<Product,
ProductCategory>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name],
[x].[Price], [x.Category].[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].
[CategoryId] = [x.Category].[Id]
WHERE [x].[Name] = N'Optimus Prime',
shaper:
TypedCompositeShaper<BufferedOffsetEntityShaper<Product>, Product,
BufferedOffsetEntityShaper<ProductCategory>, ProductCategory,
TransparentIdentifier<Product, ProductCategory>>),
selector: (TransparentIdentifier<Product, ProductCategory> t0)
=> Product _Include(
queryContext: queryContext,
entity: t0.Outer,
included: new object[]{ t0.Inner },
fixup: (QueryContext queryContext | Product entity |
Object[] included) =>
{
Void queryContext.QueryBuffer.StartTracking(
entity: entity,
entityType: EntityType: Product)
return !(bool ReferenceEquals(included[0], null)) ?
{
Void queryContext.QueryBuffer.StartTracking(
entity: included[0],
entityType: EntityType: ProductCategory)
Void SetRelationshipSnapshotValue(
stateManager: queryContext.StateManager,
navigation: Product.Category,
entity: entity,
value: included[0])
return Void AddToCollectionSnapshot(
stateManager: queryContext.StateManager,
navigation: ProductCategory.Products,
entity: included[0],
value: entity)
}
: default(Void)
}
)))),
queryContext: Unhandled parameter: queryContext,
entityTrackingInfos: { itemType: Product },
entityAccessors: List<Func<Product, object>>
{
Func<Product, Product>,
}
),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: Unhandled parameter: queryContext)Opening connection to database
'FeaturesDb' on server '.'.Opened connection to database 'FeaturesDb' on server
'.'.Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (63ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Compiling query model:
'(from Product x in DbSet<Product>
where [x].Name == "Barbie"
select new <>f__AnonymousType0<string, string>(
[x].Name,
string [x].Price.ToString("C2")
)).FirstOrDefault()'Optimized query model:
'(from Product x in DbSet<Product>
where [x].Name == "Barbie"
select new <>f__AnonymousType0<string, string>(
[x].Name,
string [x].Price.ToString("C2")
)).FirstOrDefault()'(QueryContext queryContext) =>
IEnumerable<<>f__AnonymousType0<string, string>> _InterceptExceptions(
source: IEnumerable<<>f__AnonymousType0<string, string>>
_ToSequence(<>f__AnonymousType0<string, string>
FirstOrDefault(IEnumerable<<>f__AnonymousType0<string, string>> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie',
shaper: TypedProjectionShaper<ValueBufferShaper, ValueBuffer,
<>f__AnonymousType0<string, string>>))),
contextType: CoreFeaturesDemo.Data.FeaturesDbContext,
logger: DiagnosticsLogger<Query>,
queryContext: queryContext)Opening connection to database 'FeaturesDb' on
server '.'.Opened connection to database 'FeaturesDb' on server '.'.Executing
DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (18ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'A data reader was disposed.Closing connection to
database 'FeaturesDb' on server '.'.Closed connection to database 'FeaturesDb' on
server '.'.Executing DbCommand [Parameters=[], CommandType='Text',
CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (82ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'A data reader was disposed.Executing DbCommand
[Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (15ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'A data reader was disposed.Executed DbCommand (68ms)
[Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (12ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (98ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (14ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (13ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[Price]
FROM [Products] AS [p]Executed DbCommand (102ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (27ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (13ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[Price]
FROM [Products] AS [p]Executed DbCommand (93ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (14ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (12ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[Price]
FROM [Products] AS [p]Executed DbCommand (69ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (15ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (16ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[Price]
FROM [Products] AS [p]Executed DbCommand (91ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (13ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (12ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[Price]
FROM [Products] AS [p]Executed DbCommand (74ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
SELECT [p0].[Id], [p0].[CategoryId], [p0].[Name], [p0].[Price], [p.Category0].[Id],
[p.Category0].[Name]
FROM [Products] AS [p0]
INNER JOIN [ProductCategories] AS [p.Category0] ON [p0].[CategoryId] =
[p.Category0].[Id]
ORDER BY [p.Category0].[Id]Executed DbCommand (74ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p0].[Id], [p0].[CategoryId], [p0].[Name], [p0].[Price]
FROM [Products] AS [p0]
ORDER BY [p0].[CategoryId]Executed DbCommand (65ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p0].[Id], [p0].[CategoryId], [p0].[Name], [p0].[Price], [p.Category0].[Id],
[p.Category0].[Name]
FROM [Products] AS [p0]
INNER JOIN [ProductCategories] AS [p.Category0] ON [p0].[CategoryId] =
[p.Category0].[Id]
ORDER BY [p.Category0].[Id]Executed DbCommand (67ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p0].[Id], [p0].[CategoryId], [p0].[Name], [p0].[Price], [p.Category0].[Id],
[p.Category0].[Name]
FROM [Products] AS [p0]
INNER JOIN [ProductCategories] AS [p.Category0] ON [p0].[CategoryId] =
[p.Category0].[Id]
ORDER BY [p.Category0].[Id]Executed DbCommand (67ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Deleted], [c].[Name]
FROM [Countries] AS [c]
WHERE [c].[Deleted] = 0Executed DbCommand (91ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Deleted], [c].[Name]
FROM [Countries] AS [c]
WHERE [c].[Deleted] = 0Executed DbCommand (106ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (69ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price], [x.Category].
[Id], [x.Category].[Name]
FROM [Products] AS [x]
INNER JOIN [ProductCategories] AS [x.Category] ON [x].[CategoryId] = [x.Category].
[Id]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (72ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (50ms) [Parameters=[@p0='?',
@p1='?', @p2='?', @p3='?', @p4='?', @p5='?', @p6='?', @p7='?', @p8='?', @p9='?',
@p10='?', @p11='?', @p12='?', @p13='?', @p14='?'], CommandType='Text',
CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Executed DbCommand (31ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Name]
FROM [Countries] AS [c]Executed DbCommand (75ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Id], [x].[CategoryId], [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Optimus Prime'Executed DbCommand (47ms)
[Parameters=[@p0='09/02/2017 13:59:19', @p1='5', @p2='1', @p3='09/02/2017
14:00:19', @p4='5', @p5='2', @p6='09/02/2017 14:01:19', @p7='5', @p8='3',
@p9='09/02/2017 14:02:19', @p10='5', @p11='4', @p12='09/02/2017 14:03:19',
@p13='5', @p14='5'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
DECLARE @inserted0 TABLE ([Id] int, [_Position] [int]);
MERGE [PurchaseLogs] USING (
VALUES (@p0, @p1, @p2, 0),
(@p3, @p4, @p5, 1),
(@p6, @p7, @p8, 2),
(@p9, @p10, @p11, 3),
(@p12, @p13, @p14, 4)) AS i ([Created], [ProductId], [Quantity], _Position) ON 1=0
WHEN NOT MATCHED THEN
INSERT ([Created], [ProductId], [Quantity])
VALUES (i.[Created], i.[ProductId], i.[Quantity])
OUTPUT INSERTED.[Id], i._Position
INTO @inserted0;

SELECT [t].[Id] FROM [PurchaseLogs] t


INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id])
ORDER BY [i].[_Position];Executed DbCommand (12ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Name]
FROM [Countries] AS [c]Executed DbCommand (69ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [x].[Name], [x].[Price]
FROM [Products] AS [x]
WHERE [x].[Name] = N'Barbie'Executed DbCommand (13ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Name]
FROM [Countries] AS [c]Executed DbCommand (64ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [p].[Id], [p].[CategoryId], [p].[Name], [p].[Price]
FROM [Products] AS [p]Executed DbCommand (63ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
SELECT [p0].[Id], [p0].[CategoryId], [p0].[Name], [p0].[Price], [p.Category0].[Id],
[p.Category0].[Name]
FROM [Products] AS [p0]
INNER JOIN [ProductCategories] AS [p.Category0] ON [p0].[CategoryId] =
[p.Category0].[Id]
ORDER BY [p.Category0].[Id]Executed DbCommand (69ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Deleted], [c].[Name]
FROM [Countries] AS [c]
WHERE [c].[Deleted] = 0Executed DbCommand (65ms) [Parameters=[],
CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[Deleted], [c].[Name]
FROM [Countries] AS [c]
WHERE [c].[Deleted] = 0

You might also like