Compartilhar via


Método IdentifierCollection.Create

Cria um objeto identificador.

Espaço para nome Microsoft.Office.Server.ApplicationRegistry.Administration
Conjunto de Módulos (Assembly) Microsoft.SharePoint.Portal (em microsoft.sharepoint.portal.dll)

A sintaxe

Public Function Create ( _
    name As String, _
    isCached As Boolean, _
    typeName As String _
) As Identifier

Dim instance As IdentifierCollection
Dim name As String
Dim isCached As Boolean
Dim typeName As String
Dim returnValue As Identifier

returnValue = instance.Create(name, isCached, typeName)
public Identifier Create (
    string name,
    bool isCached,
    string typeName
)

Parâmetros

  • name
    O nome do identificador.
  • isCached
    true se o identificador deve ser armazenada em cache; caso contrário, false.
  • typeName
    O nome tipo do identificador.

Retornar valor

Um objeto Identifier T:Microsoft.Office.Server.ApplicationRegistry.Administration.Identifier.

Exemplo

Este exemplo cria uma entidade chamado ProductModel de banco de dados de AdventureWorks2000.

Prerequisites

Project References

Adicione o seguinte referências do projeto no seu projeto código do aplicativo console antes execução neste exemplo:

  • 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();
            CreateEntity();
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
        static void SetupBDC()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
        }
        static void CreateEntity()
        {
            LobSystemInstance mySysInstance = null;
            LobSystemInstanceCollection sysInsCollection = ApplicationRegistry.Instance.GetLobSystemInstancesLikeName("AdventureWorksSampleFromCode");
            foreach (LobSystemInstance sysInstance in sysInsCollection)
            {
                if (sysInstance.Name == "AdventureWorksSampleFromCode")
                {
                    mySysInstance = sysInstance;
                    break;
                }
            }
            IList<Entity> entityCollection = new List<Entity>(mySysInstance.LobSystem.Entities);
            Entity newEntity = mySysInstance.LobSystem.Entities.Create("ProductModel", true);
            EntityCollection entityColl = mySysInstance.LobSystem.Entities;
            foreach (Entity entity in entityColl)
            {
                if (entity.Name == "ProductModel")
                {
                    entity.Identifiers.Create("ProductModelID", true, "System.Int32");
                    break;
                }
            }
            Console.WriteLine("Created the entity successfully.");
        }
    }
}

Consulte também

Referência

IdentifierCollection De classe
IdentifierCollection Membros
Microsoft.Office.Server.ApplicationRegistry.Administration De espaço para nome