Entity.Execute, méthode (MethodInstance, LobSystemInstance, ref Object[]) (Microsoft.Office.Server.ApplicationRegistry.MetadataModel)
Executes a MethodInstance on the business application.
Espace de noms : Microsoft.Office.Server.ApplicationRegistry.MetadataModel
Assembly : Microsoft.SharePoint.Portal (dans microsoft.sharepoint.portal.dll)
Syntaxe
'Déclaration
Public Overrides Function Execute ( _
methodInstanceToExecute As MethodInstance, _
lobSystemInstance As LobSystemInstance, _
ByRef overrideArgs As Object() _
) As Object
'Utilisation
Dim instance As Entity
Dim methodInstanceToExecute As MethodInstance
Dim lobSystemInstance As LobSystemInstance
Dim overrideArgs As Object()
Dim returnValue As Object
returnValue = instance.Execute(methodInstanceToExecute, lobSystemInstance, overrideArgs)
public override Object Execute (
MethodInstance methodInstanceToExecute,
LobSystemInstance lobSystemInstance,
ref Object[] overrideArgs
)
Paramètres
- methodInstanceToExecute
MethodInstance object to execute.
- lobSystemInstance
The LobSystem object.
- overrideArgs
Overridden arguments.
Valeur de retour
An object containing the entity instances returned by the method instance.
Exemple
This example shows the use of the Execute method to do a raw method execution. This ExecuteEntityOverrideArgs method in the example also shows how to override the default values of the parameters with different values before execution.
Notes
Though this example takes the example of executing a Finder method, you will typically not use Entity.Execute to execute Finder methods. To execute methodinstances of type specificfinder and finder, you can use the FindFiltered and FindSpecific methods.
Prerequisites
Ensure a Shared Service Provider is already created.
Replace the constant value EnterYourSSPNameHere in the code with the name of your Shared Resource Provider.
Make sure the LobSystem object and entity names referenced in the example exist in the Business Data Catalog. Use valid names.
Project References
Add the following Project References in your console application code project before running this sample:
Microsoft.SharePoint
Microsoft.SharePoint.Portal
Microsoft.Office.Server
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Microsoft.Office.Server.ApplicationRegistry.MetadataModel;
using Microsoft.Office.Server.ApplicationRegistry.Runtime;
using Microsoft.Office.Server.ApplicationRegistry.SystemSpecific;
using Microsoft.Office.Server.ApplicationRegistry.Infrastructure;
using WSSAdmin = Microsoft.SharePoint.Administration;
using OSSAdmin = Microsoft.Office.Server.Administration;
namespace Microsoft.SDK.SharePointServer.Samples
{
class ExecuteEntity
{
const string yourSSPName ="EnterYourSSPNameHere";
static void Main(string[] args)
{
SetupBDC();
ExecuteEntity();
ExecuteEntityOverrideArgs();
Console.WriteLine("Press any key to exit...");
Console.Read();
}
static void SetupBDC()
{
SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
}
static void ExecuteEntity()
{
NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
Entity prodEntity = AdvWorksIns.GetEntities()["Product"];
MethodInstance methInst = prodEntity.GetFinderMethodInstance();
IEntityInstanceEnumerator prodEntityInstanceEnumerator =
(IEntityInstanceEnumerator)prodEntity.Execute(methInst,
AdvWorksIns);
while (prodEntityInstanceEnumerator.MoveNext())
{
IEntityInstance IE = prodEntityInstanceEnumerator.Current;
foreach (Field f in prodEntity.GetFinderView().Fields)
Console.Write(IE[f]);
Console.WriteLine("");
}
}
static void ExecuteEntityOverrideArgs()
{
NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
Entity prodEntity = AdvWorksIns.GetEntities()["Product"];
MethodInstance methInst = prodEntity.GetFinderMethodInstance();
Object[] args = methInst.GetMethod().CreateDefaultParameterInstances(methInst);
//Min ProductID
args[0] = 1;
//Max Product ID
args[1] = 10;
IEntityInstanceEnumerator prodEntityInstanceEnumerator =
(IEntityInstanceEnumerator)
prodEntity.Execute(methInst, AdvWorksIns, ref args);
while (prodEntityInstanceEnumerator.MoveNext())
{
IEntityInstance IE = prodEntityInstanceEnumerator.Current;
foreach (Field f in prodEntity.GetFinderView().Fields)
Console.Write(IE[f]);
Console.WriteLine("");
}
}
}
}
Voir aussi
Référence
Entity, classe
Membres Entity
Microsoft.Office.Server.ApplicationRegistry.MetadataModel, espace de noms