DataServiceContext.SetSaveStream Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets a new data stream as the binary property of an entity.
Overloads
SetSaveStream(Object, Stream, Boolean, DataServiceRequestArgs) |
Sets a new data stream as the binary property of an entity, with the specified settings in the request message. |
SetSaveStream(Object, Stream, Boolean, String, String) |
Sets a new data stream as the binary property of an entity. The specified Content-Type and Slug headers are included in the request message. |
SetSaveStream(Object, Stream, Boolean, DataServiceRequestArgs)
Sets a new data stream as the binary property of an entity, with the specified settings in the request message.
public:
void SetSaveStream(System::Object ^ entity, System::IO::Stream ^ stream, bool closeStream, System::Data::Services::Client::DataServiceRequestArgs ^ args);
public void SetSaveStream (object entity, System.IO.Stream stream, bool closeStream, System.Data.Services.Client.DataServiceRequestArgs args);
member this.SetSaveStream : obj * System.IO.Stream * bool * System.Data.Services.Client.DataServiceRequestArgs -> unit
Public Sub SetSaveStream (entity As Object, stream As Stream, closeStream As Boolean, args As DataServiceRequestArgs)
Parameters
- entity
- Object
The entity that has a binary property to which to assign the data stream.
- closeStream
- Boolean
A Boolean value that determines whether the data stream is closed when the SaveChanges() method is completed.
An instance of the DataServiceRequestArgs class that contains settings for the HTTP request message.
Exceptions
Any of the parameters supplied to the method are null
.
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 is associated with the entity
, which is called a Media Link Entry.
Calling the SetSaveStream method marks the entity as a 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 args
. Therefore, do not change an HTTP header in a way that changes the meaning of the request.
Applies to
SetSaveStream(Object, Stream, Boolean, String, String)
Sets a new data stream as the binary property of an entity. The specified Content-Type and Slug headers are included in the request message.
public:
void SetSaveStream(System::Object ^ entity, System::IO::Stream ^ stream, bool closeStream, System::String ^ contentType, System::String ^ slug);
public void SetSaveStream (object entity, System.IO.Stream stream, bool closeStream, string contentType, string slug);
member this.SetSaveStream : obj * System.IO.Stream * bool * string * string -> unit
Public Sub SetSaveStream (entity As Object, stream As Stream, closeStream As Boolean, contentType As String, slug As String)
Parameters
- entity
- Object
The entity that has a binary property to which to assign the data stream.
- closeStream
- Boolean
A Boolean value that determines whether the data stream is closed when the SaveChanges() method is completed.
- contentType
- String
The Content-Type header value for the request message.
- slug
- String
The Slug header value for the request message.
Exceptions
Any of the parameters supplied to the method are null
.
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 is associated with 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.