DataServiceContext.SetSaveStream Method (Object, Stream, Boolean, String, String)

Sets a binary data stream that belongs to the specified entity, with the specified Content-Type and Slug headers in the request message.

Namespace:  System.Data.Services.Client
Assembly:  Microsoft.Data.Services.Client (in Microsoft.Data.Services.Client.dll)

Syntax

'Declaration
Public Sub SetSaveStream ( _
    entity As Object, _
    stream As Stream, _
    closeStream As Boolean, _
    contentType As String, _
    slug As String _
)
'Usage
Dim instance As DataServiceContext 
Dim entity As Object 
Dim stream As Stream 
Dim closeStream As Boolean 
Dim contentType As String 
Dim slug As String

instance.SetSaveStream(entity, stream, _
    closeStream, contentType, slug)
public void SetSaveStream(
    Object entity,
    Stream stream,
    bool closeStream,
    string contentType,
    string slug
)
public:
void SetSaveStream(
    Object^ entity, 
    Stream^ stream, 
    bool closeStream, 
    String^ contentType, 
    String^ slug
)
member SetSaveStream : 
        entity:Object * 
        stream:Stream * 
        closeStream:bool * 
        contentType:string * 
        slug:string -> unit
public function SetSaveStream(
    entity : Object, 
    stream : Stream, 
    closeStream : boolean, 
    contentType : String, 
    slug : String
)

Parameters

  • entity
    Type: System.Object
    The entity to which the data stream belongs.
  • contentType
    Type: System.String
    The Content-Type header value for the request message.
  • slug
    Type: System.String
    The Slug header value for the request message.

Exceptions

Exception Condition
ArgumentNullException

Any of the parameters supplied to the method are nulla null reference (Nothing in Visual Basic).

ArgumentException

The entity is not being tracked by this DataServiceContext instance.

-or-

The entity has the MediaEntryAttribute applied.

Remarks

The SetSaveStream method sets the binary stream that is the Media Resource that belongs to the entity, which is called a Media Link Entry.

Calling the SetSaveStream method marks the entity as Media Link Entry. The entity state is also set to Modified so that the stream will be sent to the data service the next time that the SaveChanges method is called.

The SetSaveStream method reads the Stream through to the end. A Seek operation is not tried on the Stream.

When closeStream is true, the SaveChanges method closes the stream before it returns. The stream is closed even when an error occurs and the stream is not read.

When the entity has the MediaEntryAttribute applied, the Media Resource cannot be a data stream. Remove this attribute before you try to set the data stream for the entity.

No validation is performed on the headers that are set in contentType and slug. Therefore, do not change these HTTP headers in a way that changes the meaning of the request.

See Also

Reference

DataServiceContext Class

SetSaveStream Overload

System.Data.Services.Client Namespace