Search for existing suggestions

Support for streams instead of byte arrays for varbinary fields

Support for mapping System.IO.Stream to Binary fields

107 votes
Sign in
(thinking…)
Password icon
Signed in as (Sign out)

We’ll send you updates on this idea

Mike Flasko shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

8 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Werner Strydom commented  ·   ·  Flag as inappropriate

    We work with documents a lot and store them in the database. A stream makes sense as it can come in many forms, be it an http stream, file stream or memory stream. If the underlying provider supports streaming and chunking, it may also reduce fragmentation of the large object heap and ultimately performance of the system as a whole. This is a problem when many documents exceed 85k.

    There are a number of examples how to upload large files to varbinary columns in SQL Server 2005.

    In addition, when you read data, the byte array is often populated by EF, which itself causes memory problems, mentioned earlier. So EF can treat a stream as a lazy field and only connect to the database to download the large stream when really needed, while keeping memory requirements to a minimum.

  • Ladislav Mrnka commented  ·   ·  Flag as inappropriate

    This request doesn't make sense. There is no streaming between database and application except FILESTREAM which works only per record and requires two different queries - it would be a very special type of per column lazy loading but it will be SQL Server only.

  • Eamon Nerbonne commented  ·   ·  Flag as inappropriate

    Does SQL server itself even support lazy streams? Isn't that what FILESTREAM types are for? I.e. implementing this is effectively going to be a wrapper around something closely equivalent to MemoryStream - not much point...

  • crpietschmann commented  ·   ·  Flag as inappropriate

    Why would you be storing a 3GB binary blob/file in a database? You should store that in a file somewhere and then use a Stream to read it as necessary.

  • Vesel commented  ·   ·  Flag as inappropriate

    I think, "Lazy Loading at Column Level" feature has the same general idea. May be merge?

  • matt commented  ·   ·  Flag as inappropriate

    I think of using a streaming contract rather than to convert all bytes to a stream on the client side.

  • Vesel commented  ·   ·  Flag as inappropriate

    Stream is abstract type. The only concrete type I see for mapping is MemoryStream. But If you need you can get MemoryStream from bytes with only one line of code
    MemoryStream stream = new MemoryStream(bytes)

Feedback and Knowledge Base