System.OutOfMemoryException - when Entity Framework is querying a too big data of Varbinary type

前端 未结 3 1081
野性不改
野性不改 2021-01-20 06:34

I\'m trying to query a varbinary column that contain a file (1,2 Gb).

I\'m using Entity Framework. See below:

Database to test

C         


        
3条回答
  •  粉色の甜心
    2021-01-20 07:00

    It appears Entity Framework doesn't support streaming the data to a varbinary field.

    You have a couple of options.

    • Drop to ADO.NET for the large transfers.
    • Switch your database to FileStream instead of varbinary

    Edit: Assuming you're using .NET 4.5, you should use SqlDataReader.GetStream. This will allow streaming the file without having to load the whole thing into memory.

提交回复
热议问题