Parameter Class

NOTE: This API is now obsolete.

Represents the in, inout, out and return parameters of each method.

Inheritance Hierarchy

System.Object
  Microsoft.Office.Server.ApplicationRegistry.Administration.MetadataObject
    Microsoft.Office.Server.ApplicationRegistry.Administration.AccessControlledMetadataObject
      Microsoft.Office.Server.ApplicationRegistry.Administration.Parameter

Namespace:  Microsoft.Office.Server.ApplicationRegistry.Administration
Assembly:  Microsoft.SharePoint.Portal (in Microsoft.SharePoint.Portal.dll)

Syntax

'Declaration
<ObsoleteAttribute("O12 Application Registry API is deprecated. Please use BusinessData.",  _
    False)> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class Parameter _
    Inherits AccessControlledMetadataObject
'Usage
Dim instance As Parameter
[ObsoleteAttribute("O12 Application Registry API is deprecated. Please use BusinessData.", 
    false)]
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class Parameter : AccessControlledMetadataObject

Remarks

In cases where a Web method returns void, it is likely returning a value in an out parameter. You must describe that parameter as the return parameter in the metadata. A return parameter in the Business Data Catalog is the value it should read from the back-end application. Parameters contain information such as:

  • The direction of the parameter (In, Out, InOut, Return).

  • The ordinal number of the parameter in the method signature.

  • Whether the parameter is optional.

  • The TypeReflector. Every Parameter object contains a TypeReflector. The TypeReflector is responsible for instantiating a Parameter object filled with default values according to the structure indicated by the TypeDescriptor, and getting or setting values for individual fields referenced by type descriptors in the instantiated Parameter object.

For Web methods, parameter names are tokens used by the Business Data Catalog. Though they must be unique for a given method, you can name them anything. TypeDescriptor names, however, must exactly match the structures and fields returned by the back-end application methods.

In the case of a database, the parameter names must exactly match the parameter names in the stored procedure or SQL query.

Examples

The following code example shows how to create a method, complete with method instances, filter descriptors, default values, and type descriptors, 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;
                }
            }
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Parameter Members

Microsoft.Office.Server.ApplicationRegistry.Administration Namespace