Condividi tramite


Profiles System Task and Object Mapping from COM to the .NET Framework

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

This topic describes how Profile objects implemented by using the Component Object Model (COM) for Commerce Server 2002 and earlier releases map to similar objects in the Commerce Server 2007 Class Library based on the .NET Framework. The scope and function of the Component Object Model (COM) Profile objects resemble that of the Profile objects available in the Commerce Server Class Library. For example, the ProfileContext type resembles a ProfileService object in COM and the Profile type resembles the COM ProfileObject type.

In the COM model for the Commerce Server Profiles system, there are three entities, all scoped to Active Server Pages (ASP) applications:

  • Profile service instance

  • OLE DB Provider for Commerce Server instance

  • BizDataAdmin object instance

In the .NET Framework model, the key profile service functionality is provided by the OLE DB Provider for Commerce Server and selected site term-related functionality. These are implemented in a single ProfileContext object.

Object Mapping

The .NET Framework types in the following table are in the Microsoft.CommerceServer.Runtime.Profiles namespace:

COM

.NET Framework

ProfileService

ProfileContext

ProfileObject

Profile

ProfileObject.Fields

ProfilePropertyCollection

ProfilePropertyGroupCollection

Task Mapping

The following sections contain common coding tasks and show you the COM and the .NET Framework approach to coding the solution.

Accessing the Global Profile Service Instance

COM

.NET Framework

Application(MSCSProfileService)

ProfileSystem

Creating a New Profile

COM

.NET Framework

ProfileService.CreateProfile

CreateProfile

Retrieving an Existing Profile

COM

.NET Framework

ProfileService.GetProfile

GetProfile

Deleting a Profile

COM

.NET Framework

ProfileService.DeleteProfile

DeleteProfile

Setting a Profile Property Value

COM

.NET Framework

profileObject.GeneralInfo.logon_<name> = <value>

Where profileObject is an existing Profile object.

profileObject[GeneralInfo.logon_name] = <name>;

Where profileObject is an instance of Profile.

Alternative ways:

  • ProfilePropertyGroupCollection ppgc = profileObject[GeneralInfo];

    ProfileProperty pp = ppgc[logon_name];

    pp.Value = <value>;

  • profileObject.Properties[GeneralInfo.first_name].Value = <value>;

  • profileObject.PropertyGroups[GeneralInfo][last_name].Value = <value>;

Retrieving a Profile Property Value

COM

.NET Framework

logonName = profileObject.GeneralInfo.logon_name

Where profileObject is an existing Profile object.

String logonName = profileObject[GeneralInfo.logon_name];

Where profileObject is an instance of Profile.

Alternative ways:

  • ProfilePropertyGroupCollection ppgc = profileObject[GeneralInfo];

    ProfileProperty pp = ppgc[logon_name];

    String logonName = pp.Value as string;

  • String logonName = (String) profileObject.Properties[GeneralInfo.first_name].Value;

  • String logonName = (String) profileObject.PropertyGroups[GeneralInfo][last_name].Value;

Retrieving Immediate Profile Property Collection

COM

.NET Framework

Loop through the Fields collections of the profile object and check to see whether each field is a property or a property group. For example:

For Each profileField In profileObject.Fields
  ' Profile property group case
  If IsObject(profileField) Then
    ' Statements
  ' Profile property case
  Else
    ' Statements
  End If
Next

Profile and ProfilePropertyGroup in ProfilePropertyCollection

Retrieving Immediate Profile Property Group Collection

COM

.NET Framework

Loop through Fields collections of the profile object and check to see whether the field is a property or a property group. For example:

For Each profileField In profileObject.Fields
  ' Profile property group case
 If IsObject(profileField) Then
  
  ' Profile property case
 Else
  ' Statements
 End If
Next

Profile and ProfilePropertyGroup in ProfilePropertyGroupCollection

Retrieving Profile Property Attributes

COM

.NET Framework

Loop through the Fields collections for the profile object and check whether the field is a property or a property group. For example:

For Each profileField In profileObject.Fields
  ' Profile property group case
 If IsObject(profileField) Then
  
  ' Profile property case
 Else
  
  Set profileAttributes = profileField.Properties
  For Each profileAttribute in profileAttributes
  Next
 End If
Next

Attributes

Retrieving Site Term Names

COM

.NET Framework

Call the GetSiteTerms method of the BizDataAdmin object, and then parse the returned XML stream for the site term names.

SiteTermNames

Retrieving Site Terms

COM

.NET Framework

Call the GetSiteTerms method of the BizDataAdmin object, and then parse the returned XML stream for the site term.

GetSiteTerm

Accessing the Commerce OLE DB Provider (CSOLEDB)

COM

.NET Framework

Application(MSCSAdoConnection)

CommerceOleDbProvider

Executing Queries Through the OLE DB Provider for Commerce Server (CSOLEDB)

COM

.NET Framework

Use ActiveX® Data Objects (ADO) to execute queries using the OLE DB Provider for Commerce Server (CSOLEDB).

Use ADO.NET to execute queries by using the CSOLEDB.

See Also

Other Resources

Task and Object Mapping from COM to the .NET Framework