Best approach for binary column with LINQ to SQL

In my SQL 2008 table, let it call tblDocument, there are columns such as name, creator, sequenceNumber, followed by the varbinary (Document) column for DocumentContent containing the document itself.

I am using LINQ to SQL. If I want to display tblDocument lines in an interface without extracting a binary file with several megabytes of wiring for each line, what is the best way to do this? Is there a way to do this so that access to the file stream is not obtained until I read it, or something like that?

Thank!

+3
source share
1 answer

Linq , DocumentContent. :

var list = from item in db.tblDocument
  select new  
  {
    item.ID,
    item.name,
    item.creator,
    item.sequenceNumber
  };

, DocumentContent, :

var content = db.tblDocument
  .Where(x => x.ID == MyRowID)
  .Select(x => x.DocumentContent).Single();
+2

Source: https://habr.com/ru/post/1729807/


All Articles