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

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Sets a new data stream as the binary property of an entity, with the specified settings in the request message.

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

public void SetSaveStream(
	object entity,
	Stream stream,
	bool closeStream,
	DataServiceRequestArgs args
)

Parameters

entity
Type: System.Object

The entity that has a binary property to which to assign the data stream.

stream
Type: System.IO.Stream

The Stream from which to read the binary data.

closeStream
Type: System.Boolean

A Boolean value that determines whether the data stream is closed when the SaveChanges method is completed.

args
Type: System.Data.Services.Client.DataServiceRequestArgs

An instance of the DataServiceRequestArgs class that contains settings for the HTTP request message.

Exception Condition
ArgumentNullException

Any of the parameters supplied to the method are null.

ArgumentException

The entity is not being tracked by this DataServiceContext instance.

-or-

The entity has the MediaEntryAttribute applied.

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.

.NET Framework
Available since 3.5
Silverlight
Available since 4.0
Return to top
Show: