Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PropertyKind Enumeration

Specifies the kinds of item attributes in the conceptual model.

Namespace:  System.Data.Metadata.Edm
Assembly:  System.Data.Entity (in System.Data.Entity.dll)
public enum PropertyKind
Member nameDescription
ExtendedAn enumeration member indicating that an item attribute is Extended.
SystemAn enumeration member indicating that an item attribute is System.

For more information, see Extended Property (CSDL).

The following code sample demonstrates how to get a metadata workspace from the connection and then use that metadata workspace to retrieve information about the extended properties in the specified data model. Note that the metadata workspace is a runtime service component that provides support for retrieving metadata.

The code sample uses a CSpace to specify the model. The CSpace represents the default name for the conceptual model. The code sample uses the AdventureWorks Model that is provided in the AdventureWorks Model (EDM)topic. For an example of the application config file, see AdventureWorks Object Model in Applications (EDM).

using System;
using System.Data;
using System.Data.EntityClient;
using System.Collections.ObjectModel;
using System.Data.Metadata.Edm;

class UsePropertyKindExample
{
   static void Main(string[] args)
   {
     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"))
       {
          // Open the connection.
          connection.Open();
           
          // Access the metadata workspace.
          MetadataWorkspace workspace = 
             connection.GetMetadataWorkspace();

          // Display the extended properties in the conceptual model.
          DisplayProperties(workspace, DataSpace.CSpace);
       }
     }
     catch (MetadataException exceptionMetadata)
     {
         Console.WriteLine("MetadataException: {0}",
                         exceptionMetadata.Message);
     }
     catch (System.Data.MappingException exceptionMapping)
     {
         Console.WriteLine("MappingException: {0}",
                          exceptionMapping.Message);
     }
   }

   public static void DisplayProperties(
        MetadataWorkspace workspace, DataSpace model)
   {
      // Get a collection of the entity containers.
      ReadOnlyCollection<EntityContainer> containers =
          workspace.GetItems<EntityContainer>(model);

      // Iterate through the collection to get each entity container.
      foreach (EntityContainer container in containers)
      {
          // Display the extended properties for the entity container.
          DisplayExtendedProperties(container);

          // Iterate through the collection to get each entity set.
          foreach (EntitySetBase baseSet in container.BaseEntitySets)
          {
              // Check whether this instance is an EntitySet.
              if (baseSet is EntitySet)
              {
                 // Display the extended properties for the entity set.
                 DisplayExtendedProperties(baseSet);
              }
          }
      }

      // Get a collection of the entity types.
      ReadOnlyCollection<EntityType> entities = 
             workspace.GetItems<EntityType>(model);

      // Iterate through the collection to get each entity type.
      foreach (EntityType entity in entities)
      {
         // Display the extended properties for the entity type.
         DisplayExtendedProperties(entity);
      }
   }

   private static void DisplayExtendedProperties(MetadataItem item)
   {
     foreach (MetadataProperty property in item.MetadataProperties)
     {
         if (property.PropertyKind == PropertyKind.Extended)
           Console.WriteLine(string.Format("\t{0}\t{1}\t{2}", 
             item.GetType().Name, property.Name, property.Value));
     }
   }
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft. All rights reserved.