我正在尝试在IDBcommandInterceptor
插入/更新操作上模拟 EF,这很简单 - 我可以返回DbDataReader
由单个字段或 int 组成的但是,对于选择操作,如果有一些“包含”,那么 sql 结果的形状很漂亮……棒极了
我怎么能从
ReaderExecuting(DbCommand command, DbCommandInterceptionContext<DbDataReader>
结果的字段和名称以及相应的实体DbDataReader
?
谢谢,
示例:尝试读取Department(Id, Name) from Id with include on Employee(Id, Name .IDDepartment, DateModification, DateCreation, User)
获取包含的 DBDataReader 的命令如下。
我想知道能够模拟的字段名称(如C1
、ID1
和其他)。Name1
SELECT
[Project2].[Id] AS [Id],
[Project2].[Name] AS [Name],
[Project2].[C1] AS [C1],
[Project2].[Id1] AS [Id1],
[Project2].[Name1] AS [Name1],
[Project2].[IDDepartment] AS [IDDepartment],
[Project2].[DateModification] AS [DateModification],
[Project2].[DateCreation] AS [DateCreation],
[Project2].[User] AS [User],
[Project2].[Archive] AS [Archive]
FROM ( SELECT
[Limit1].[Id] AS [Id],
[Limit1].[Name] AS [Name],
[Extent2].[Id] AS [Id1],
[Extent2].[Name] AS [Name1],
[Extent2].[IDDepartment] AS [IDDepartment],
[Extent2].[DateModification] AS [DateModification],
[Extent2].[DateCreation] AS [DateCreation],
[Extent2].[User] AS [User],
[Extent2].[Archive] AS [Archive],
CASE WHEN ([Extent2].[Id] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1]
FROM (SELECT TOP (1)
[Extent1].[Id] AS [Id],
[Extent1].[Name] AS [Name]
FROM [dbo].[Department] AS [Extent1]
WHERE [Extent1].[Id] = @p__linq__0 ) AS [Limit1]
LEFT OUTER JOIN [dbo].[Employee] AS [Extent2] ON [Limit1].[Id] = [Extent2].[IDDepartment]
) AS [Project2]
ORDER BY [Project2].[Id] ASC, [Project2].[C1] ASC