Retrieve an object from entityframework without ONE field

后端 未结 8 2360
[愿得一人]
[愿得一人] 2020-11-30 02:54

I\'m using entity framework to connect with the database. I\'ve one little problem:

I\'ve one table which have one varbinary(MAX) column(with filestream).

I\

8条回答
  •  感动是毒
    2020-11-30 03:34

    For EF Core 2 I implemented a solution like this:

    var files = context.Files.AsNoTracking()
                             .IgnoreProperty(f => f.Report)
                             .ToList();
    

    The base idea is to turn for example this query:

    SELECT [f].[Id], [f].[Report], [f].[CreationDate]
    FROM [File] AS [f]
    

    into this:

    SELECT [f].[Id], '' as [Report], [f].[CreationDate]
    FROM [File] AS [f]
    

    you can see the full source code in here: https://github.com/aspnet/EntityFrameworkCore/issues/1387#issuecomment-495630292

提交回复
热议问题