GlobalItem Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Representerar basobjektklassen för alla konceptuella modelltyper och entitetscontainrar.
public ref class GlobalItem abstract : System::Data::Metadata::Edm::MetadataItem
public abstract class GlobalItem : System.Data.Metadata.Edm.MetadataItem
type GlobalItem = class
inherit MetadataItem
Public MustInherit Class GlobalItem
Inherits MetadataItem
- Arv
- Härledda
Exempel
Följande kodexempel visar hur du hämtar en metadataarbetsyta från anslutningen och sedan använder den metadataarbetsytan för att bläddra i metadatatypshierarkin. Observera att metadataarbetsytan är en körningstjänstkomponent som ger stöd för att hämta metadata.
Kodexemplet använder en CSpace för att ange modellen. CSpace Representerar standardnamnet för den konceptuella modellen. Kodexemplet använder reťazec pripojenia som anges i programkonfigurationsfilen.
using System;
using System.Data;
using System.Data.EntityClient;
using System.Data.Metadata.Edm;
using System.Collections.ObjectModel;
class BrowseTypes
{
static void Main()
{
try
{
// Establish a connection to the underlying data provider by
// using the connection string specified in the config file.
using (EntityConnection connection =
new EntityConnection("Name=AdventureworksContext"))
{
// Access the metadata workspace.
MetadataWorkspace workspace =
connection.GetMetadataWorkspace();
// Browse the metadata type hierarchy.
BrowseTypesExample(workspace);
}
}
catch (MetadataException exceptionMetadata)
{
Console.WriteLine("MetadataException: {0}",
exceptionMetadata.Message);
}
catch (System.Data.MappingException exceptionMapping)
{
Console.WriteLine("MappingException: {0}",
exceptionMapping.Message);
}
}
private static void BrowseTypesExample(MetadataWorkspace workspace)
{
// Get a collection of the GlobalItems.
// An GlobalItem class is the base class for
// the conceptual model types and entity containers.
ReadOnlyCollection<GlobalItem> items =
workspace.GetItems<GlobalItem>(DataSpace.CSpace);
// Iterate through the collection to get each item.
foreach (GlobalItem item in items)
{
Console.WriteLine(
"Item BuiltInTypeKind: {0}, Type: {1} ",
item.BuiltInTypeKind, item.GetType().FullName);
EntityContainer entityContainer = item as EntityContainer;
if (entityContainer != null)
{
Console.WriteLine(
"EntityContainer Name: {0}",
entityContainer.Name);
continue;
}
EntityType entityType = item as EntityType;
if (entityType != null)
{
Console.WriteLine(
"EntityType Name: {0}, Namespace: {1}",
entityType.Name, entityType.NamespaceName);
continue;
}
AssociationType associationType = item as AssociationType;
if (associationType != null)
{
Console.WriteLine(
"AssociationType Name: {0}, Namespace: {1}",
associationType.Name, associationType.NamespaceName);
continue;
}
PrimitiveType primType = item as PrimitiveType;
if (primType != null)
{
Console.WriteLine(
"PrimitiveType Name: {0}, Namespace: {1}",
primType.Name, primType.NamespaceName);
continue;
}
EdmFunction function = item as EdmFunction;
if (function != null)
{
Console.WriteLine(
"EdmFunction Name: {0}, Namespace: {1}",
function.Name, function.NamespaceName);
continue;
}
}
}
}
Egenskaper
| Name | Description |
|---|---|
| BuiltInTypeKind |
Hämtar den inbyggda typen för den här typen. (Ärvd från MetadataItem) |
| Documentation |
Hämtar eller anger den dokumentation som är associerad med den här typen. (Ärvd från MetadataItem) |
| MetadataProperties |
Hämtar listan över egenskaper för den aktuella typen. (Ärvd från MetadataItem) |
Metoder
| Name | Description |
|---|---|
| Equals(Object) |
Avgör om det angivna objektet är lika med det aktuella objektet. (Ärvd från Object) |
| GetHashCode() |
Fungerar som standard-hash-funktion. (Ärvd från Object) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |