Compartir a través de


: Method (Clase) (Microsoft.Office.Server.ApplicationRegistry.Administration)

Represents operations related to an entity that you can perform in the line-of-business (LOB) application.

Espacio de nombres:
Ensamblado: Microsoft.SharePoint.Portal (in microsoft.sharepoint.portal.dll)

Sintaxis

'Declaración
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel:=True)> _
Public Class Method
    Inherits IndividuallySecurableMetadataObject
'Uso
Dim instance As Method
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel=true)] 
public class Method : IndividuallySecurableMetadataObject

Comentarios

Methods represent pointers to business logic in a business application. Examples of methods are "get a list of customers," "get the order with a specified ID," and "update the unit price of a product."

The metadata for a Method essentially describes a method signature; for example, the name of an SQL stored procedure, an SQL query, or a Web services method. The definitions for the method signatures live in the LOB application. The Method metadata object provides the information about that method so the Runtime object model can query the metadata repository for this information when a client wants to execute the method.

Methods contain Parameter, MethodInstance, and FilterDescriptor.

You can reuse the same back-end application method for multiple method instances in the Business Data Catalog. For example, the AdventureWorks sample reuses the GetProducts method as both Finder and SpecificFinder. The GetCustomerByID method in the SampleWebService reuses it as a SpecificFinder for customer and as an Association method to get addresses.

Importante

Business Data Catalog supports only "first" generation Web services. Therefore, if you are using Windows Communication Foundation Web Services, make sure you are using only WS-I Basic Profile v1.0. Business Data Catalog does not support the eight other binding choices that Windows Communication Foundation offers. For a sample, see the SampleWebService.

When you use Web services with overloaded methods, you cannot have multiple methods named identically in the Business Data Catalog metadata. A given entity can use only a single Web proxy method override at a given time. However, you can have multiple methods with the same name in the Web service. The Business Data Catalog will pick the correct method based on the signature in the metadata.

Following are the properties that the Method object accepts for database systems.

Property

Type

Required

Default Value

Limits/Accepted Values

RdbCommandType

System.Data.CommandType

Yes

None

Text or

StoredProcedure

RdbCommandText

System.String

Yes

None

SQL statement to execute or name of the stored procedure.

Ejemplo

The following code example shows how to create a method, complete with MethodInstances, FilterDescriptors, DefaultValues, and TypeDescriptors for the ProductModel entity in the AdventureWorks2000 database.

Prerequisites

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 Microsoft.Office.Server.ApplicationRegistry.Administration;
using Microsoft.Office.Server.ApplicationRegistry.Infrastructure;
using WSSAdmin = Microsoft.SharePoint.Administration;
using OSSAdmin = Microsoft.Office.Server.Administration;

namespace Microsoft.SDK.SharePointServer.Samples
{
    class GetStartedAndCreateSystem
    {
        const string yourSSPName ="EnterYourSSPNameHere";

        static void Main(string[] args)
        {
            SetupBDC();
            CreateFinderMethod();
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
        static void SetupBDC()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
        }
        static void CreateFinderMethod()
        {

            LobSystemInstance mySysInstance = null;
            LobSystemInstanceCollection sysInsCollection = ApplicationRegistry.Instance.GetLobSystemInstancesLikeName("AdventureWorksSampleFromCode");
            foreach (LobSystemInstance sysInstance in sysInsCollection)
            {
                if (sysInstance.Name == "AdventureWorksSampleFromCode")
                {
                    mySysInstance = sysInstance;
                    break;
                }
            }
            EntityCollection entityColl = mySysInstance.LobSystem.Entities;
            foreach (Entity entity in entityColl)
            {
                if (entity.Name == "ProductModel")
                {
                    Method meth = entity.Methods.Create("GetProductModels", true, true);
                    meth.Properties.Add("RdbCommandText", "SELECT ProductModelID, Name, CatalogDescription FROM ProductModel WHERE Name LIKE @Name");
                    meth.Properties.Add("RdbCommandType", System.Data.CommandType.Text);
                    FilterDescriptor fd = meth.FilterDescriptors.Create("Name", true, "Microsoft.Office.Server.ApplicationRegistry.Runtime.WildcardFilter");
                    Parameter p1 = meth.Parameters.Create("@Name", true, Microsoft.Office.Server.ApplicationRegistry.MetadataModel.DirectionType.In, "Microsoft.Office.Server.ApplicationRegistry.Infrastructure.DotNetTypeReflector");
                    TypeDescriptor td1 = p1.CreateRootTypeDescriptor("Name", true, "System.String", null, fd, false);
                    Parameter p2 = meth.Parameters.Create("ProductModels", true, Microsoft.Office.Server.ApplicationRegistry.MetadataModel.DirectionType.Return, "Microsoft.Office.Server.ApplicationRegistry.Infrastructure.DotNetTypeReflector");
                    IList<Identifier> ids = new List<Identifier>(entity.Identifiers);
                    Identifier id = ids[0];
                    TypeDescriptor td2 = p2.CreateRootTypeDescriptor("ProductModelDataReader", true, "System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", null, null, true);
                    TypeDescriptor td21 = td2.ChildTypeDescriptors.Create("ProductModelDataRecord", true, "System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", null, null, false);
                    TypeDescriptor td210 = td21.ChildTypeDescriptors.Create("ProductModelID", true, "System.Int32", id, null, false);
                    TypeDescriptor td211 = td21.ChildTypeDescriptors.Create("Name", true, "System.String", null, null, false);
                    TypeDescriptor td212 = td21.ChildTypeDescriptors.Create("CatalogDescription", true, "System.String", null, null, false);
                    MethodInstance methInst1 = meth.MethodInstances.Create("ProductModelFinder", true, td2, Microsoft.Office.Server.ApplicationRegistry.MetadataModel.MethodInstanceType.Finder);
                    MethodInstance methInst2 = meth.MethodInstances.Create("ProductModelSpecificFinder", true, td2, Microsoft.Office.Server.ApplicationRegistry.MetadataModel.MethodInstanceType.SpecificFinder);
                    IList<MethodInstance> methInstCollection = new List<MethodInstance>(entity.MethodInstances);
                    td1.SetDefaultValue(methInstCollection[0].Id, "%");
                    td1.SetDefaultValue(methInstCollection[1].Id, "%");
                    Console.WriteLine("Created the finder method successfully.");
                    break;
                }
            }
        }
    }
}

Jerarquía de herencia

System.Object
   Microsoft.Office.Server.ApplicationRegistry.Administration.MetadataObject
     Microsoft.Office.Server.ApplicationRegistry.Administration.AccessControlledMetadataObject
       Microsoft.Office.Server.ApplicationRegistry.Administration.IndividuallySecurableMetadataObject
        Microsoft.Office.Server.ApplicationRegistry.Administration.Method

Seguridad de subprocesos

Todos los miembros estáticos públicos (compartidos en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancia sean seguros para los subprocesos.

Vea también

Referencia

Method (Miembros)
Microsoft.Office.Server.ApplicationRegistry.Administration (Espacio de nombres)