WCF streaming SQLFileStream by Message Contract -


in wcf service, try load file ms sql table has filestream column , try pass stream back

        responsemsg.docsqlfilestream = new memorystream();          try         {             using (filestreamdbentities dbentity = new filestreamdbentities())             {                 ...                 using (transactionscope x = new transactionscope())                 {                     string sqlcmdstr = "select dcradocfile.pathname() internalpath, get_filestream_transaction_context() transactioncontext dcradocument dcradocfileid={0}";                     var docfilestreaminfo = dbentity.database.sqlquery<docfilestreampath>(sqlcmdstr, new object[] { docentity.dcradocfileid.tostring() }).first();                      sqlfilestream sqlfs = new sqlfilestream(docfilestreaminfo.internalpath, docfilestreaminfo.transactioncontext, fileaccess.read);                     sqlfs.copyto(responsemsg.docsqlfilestream);                      if( responsemsg.docsqlfilestream.length > 0 )                         responsemsg.docsqlfilestream.position = 0;                      x.complete();                 }             }             ... 

i'm wondering whats best way pass sqlfilestream through message contract take advantage of streaming. copied sqlfilestream memory stream because got error message in wcf trace says: type 'system.data.sqltypes.sqlfilestream' cannot serialized.

in webapi there such thing pushstreamcontent allows delegating transaction stuff async lambda, don't know if there similar in wcf, following approach may helpful:

http://weblogs.asp.net/andresv/archive/2012/12/12/asynchronous-streaming-in-asp-net-webapi.aspx


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -