指定されたプロパティの遅延コンテンツをデータ サービスから読み込みます。
Silverlight の WCF Data Services 5.0 クライアントではサポートされていません。
名前空間: System.Data.Services.Client
アセンブリ: Microsoft.Data.Services.Client (Microsoft.Data.Services.Client.dll)
構文
'宣言
Public Function LoadProperty ( _
entity As Object, _
propertyName As String _
) As QueryOperationResponse
'使用
Dim instance As DataServiceContext
Dim entity As Object
Dim propertyName As String
Dim returnValue As QueryOperationResponse
returnValue = instance.LoadProperty(entity, _
propertyName)
public QueryOperationResponse LoadProperty(
Object entity,
string propertyName
)
public:
QueryOperationResponse^ LoadProperty(
Object^ entity,
String^ propertyName
)
member LoadProperty :
entity:Object *
propertyName:string -> QueryOperationResponse
public function LoadProperty(
entity : Object,
propertyName : String
) : QueryOperationResponse
パラメーター
- entity
型: System.Object
読み込むプロパティを含むエンティティ。
- propertyName
型: System.String
読み込みに指定されたエンティティのプロパティの名前。
戻り値
型: System.Data.Services.Client.QueryOperationResponse
読み込み操作への応答。
説明
このメソッドを呼び出すと、プロパティ値を取得するネットワーク操作が呼び出されます。 関連付けやリンクを表すプロパティを含め、エンティティのどのプロパティでも指定できます。
プロパティが関連付け、リンク、または遅延プロパティを表す場合、このメソッドを呼び出すと、関連リソースを遅延読み込みする方法がクライアントに提供されます。
エンティティが未変更状態または変更状態にある場合は、プロパティ値は関連エンティティを読み込み、それらのエンティティを未変更のリンクと共に変更なしとマークします。
プロパティが既に読み込まれている場合は、このメソッドを呼び出すことによって、そのプロパティの値を更新できます。
使用例
次の例では、返される各 Orders インスタンスに関連付けられた Customers オブジェクトを明示的に読み込む方法を示します。 この例では、Northwind データ サービスに基づいてサービス参照の追加ツールによって生成される DataServiceContext を使用します。これは、WCF Data Services クイック スタートの完了時に作成されます。
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
Try
' Enumerate over the top 10 orders obtained from the context.
For Each order As Order In context.Orders.Take(10)
' Explicitly load the customer for each order.
context.LoadProperty(order, "Customer")
' Write out customer and order information.
Console.WriteLine("Customer: {0} - Order ID: {1}", _
order.Customer.CompanyName, order.OrderID)
Next
Catch ex As DataServiceQueryException
Throw New ApplicationException( _
"An error occurred during query execution.", ex)
End Try
// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
try
{
// Enumerate over the top 10 orders obtained from the context.
foreach (Order order in context.Orders.Take(10))
{
// Explicitly load the customer for each order.
context.LoadProperty(order, "Customer");
// Write out customer and order information.
Console.WriteLine("Customer: {0} - Order ID: {1}",
order.Customer.CompanyName, order.OrderID);
}
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException(
"An error occurred during query execution.", ex);
}