Entity, classe (Microsoft.Office.Server.ApplicationRegistry.MetadataModel)
Represents an entity such as Customer or Product, in a line-of-business (LOB) application.
Espace de noms : Microsoft.Office.Server.ApplicationRegistry.MetadataModel
Assembly : Microsoft.SharePoint.Portal (dans microsoft.sharepoint.portal.dll)
Syntaxe
'Déclaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
Public Class Entity
Inherits DataClass
'Utilisation
Dim instance As Entity
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)]
public class Entity : DataClass
Remarques
In the Business Data Catalog, an entity belongs to a single LOB system. As with all the metadata objects, it derives from the MetadataObject base class and must have a unique name.
Entities contain identifiers, methods, and actions. Entities can also have other related entities associated with them. For example, Customers and Order entities in the AdventureWorks system have an association because they share a relationship: customers make orders. This relationship is implemented as an association in the metadata.
The business objects themselves, for example, customer #88697 and order #1000 in the LOB application are referred to as entity instances. If your entity maps to a database table, you can think of an entity instance as a row.
Exemple
This example shows how to browse the metadata repository and get an LobSystem object and an Entity object.
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 GetSystemAndEntity
{
const string yourSSPName = "EnterYourSSPNameHere";
static void Main(string[] args)
{
SetupBDC();
DisplayLOBSystemsinBDC();
GetLOBSystem();
GetEntity();
Console.WriteLine("Press any key to exit...");
Console.Read();
}
static void SetupBDC()
{
SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
}
static void DisplayLOBSystemsinBDC()
{
NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
Console.WriteLine("Listing system instances...");
foreach (String name in sysInstances.Keys)
{
Console.WriteLine(name);
}
}
static void GetLOBSystem()
{
NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
Console.WriteLine("Getting a system instance and displaying its ID...");
LobSystem AdvWorksSys = AdvWorksIns.GetLobSystem();
Console.WriteLine(AdvWorksSys.Name.ToString());
Console.WriteLine("ID: "+AdvWorksSys.Id.ToString());
}
static void GetEntity()
{
NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
Console.WriteLine("Getting an entity object and displaying its ID...");
Entity prodEntity = AdvWorksIns.GetEntities()["Product"];
Console.WriteLine(prodEntity.Name.ToString());
Console.WriteLine("ID: "+prodEntity.Id.ToString());
}
}
}
Hiérarchie d'héritage
System.Object
Microsoft.Office.Server.ApplicationRegistry.MetadataModel.MetadataObject
Microsoft.Office.Server.ApplicationRegistry.MetadataModel.AccessControlledMetadataObject
Microsoft.Office.Server.ApplicationRegistry.MetadataModel.DataClass
Microsoft.Office.Server.ApplicationRegistry.MetadataModel.Entity
Sécurité des threads
Les membres statiques publics de ce type (Shared en Visual Basic) sont sécurisés au niveau des threads. Il n'est pas garanti que les membres d'instance soient sécurisés au niveau des threads.
Voir aussi
Référence
Membres Entity
Microsoft.Office.Server.ApplicationRegistry.MetadataModel, espace de noms