Profiling System Task and Object Mapping from COM to .NET

The scope and function of the COM Profile objects are similar to the Profile objects available in the Base Class Library. The ProfileContext type is similar to a ProfileService object in COM and the Profile type is similar to the COM ProfileObject type.

In COM, there were three main ASP application-scoped Profiling System related entities:

  • Profile service instance
  • OLE DB Provider for Commerce Server instance
  • BizDataAdmin object instance

In the .NET-based model, the key profile service functionality, the OLE DB Provider for Commerce Server handle, and selected site term related functionality is housed in a single ProfileContext object.

Object mapping

The .NET types in the following table are in the Microsoft.Commerceserver.Runtime.Profiles unless otherwise specified.

COM Commerce Server .NET Application Framework
ProfileService ProfileContext
ProfileObject Profile
ProfileObject.Fields ProfilePropertyCollection

ProfilePropertyGroupCollection

Task Mapping

Accessing global profile service instance

Creating a new profile

Retrieving an existing profile

Deleting a profile

Setting a profile property value

Retrieving a profile property value

Retrieving immediate profile property collection

Retrieving immediate profile property group collection

Retrieving profile property attributes

Retrieving site term names

Retrieving site terms

Accessing Commerce OLE DB Provider (CSOLEDB)

Executing queries through the Commerce OLE DB Provider

Accessing global profile service instance

ASP ASP.NET
Application(“MSCSProfileService”) CommerceContext.Current.ProfileSystem
  CommerceProfileModule.ProfileSystem (for application-level access)

Creating a new profile

ASP ASP.NET
ProfileService.CreateProfile ProfileContext.CreateProfile

Retrieving an existing profile

ASP ASP.NET
Set profileObject = ProfileService.GetProfile(“joesmith”, “UserObject”) Profile profileObject = ProfileContext.GetProfile(“joesmith”, “UserObject”)

Deleting a profile

ASP ASP.NET
ProfileService.DeleteProfile ProfileContext.DeleteProfile

Setting a profile property value

ASP ASP.NET
Assumptions: profileObject represents an existing profile object.

profileObject.GeneralInfo.logon_name = “joesmith”

Assumptions: profileObject represents an existing profile object.

profileObject[“GeneralInfo.logon_name”] = “joesmith”;

Alternative ways:

  • ProfilePropertyGroupCollection ppgc = profileObject[“GeneralInfo”];

    ProfileProperty pp = ppgc[“logon_name”];

    pp.Value = “joesmith”;

  • profileObject.Properties[“GeneralInfo.first_name”].Value = “joesmith”;
  • profileObject.PropertyGroups[“GeneralInfo”][“last_name”].Value = “joesmith”;

Retrieving a profile property value

ASP ASP.NET
Assumptions: profileObject represents an existing Profile object.

logonName = profileObject.GeneralInfo.logon_name

Assumptions: profileObject represents an existing Profile object.

String logonName = profileObject[“GeneralInfo.logon_name”];

Alternative ways:

  • ProfilePropertyGroupCollection ppgc = profileObject[“GeneralInfo”];

    ProfileProperty pp = ppgc[“logon_name”];

    String logonName = pp.Value as string;

  • String logonName = profileObject.Properties[“GeneralInfo.first_name”].Value as string;
  • String logonName = profileObject.PropertyGroups[“GeneralInfo”][“last_name”].Value;

Retrieving immediate profile property collection

ASP ASP.NET
In ASP, you must loop through all the fields in the fields collection for the profile object, explicitly checking to see if 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
  …
 End If
Next
In the .NET-based model, the profile property collection is readily available through properties in the Profile and ProfilePropertyGroup classes.

Profile.ProfilePropertyCollection

ProfilePropertyGroup.ProfilePropertyCollection

Retrieving immediate profile property group collection

ASP ASP.NET
In the COM-based model, you must loop through all the fields in the fields collection for the profile object', explicitly checking to see if 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
  …
 End If
Next
In the .NET-based model, the profile property group collection is readily available through properties in the Profile and ProfilePropertyGroup classes.

Profile.ProfilePropertyGroupCollection

ProfilePropertyGroup.ProfilePropertyGroupCollection

Retrieving profile property attributes

ASP ASP.NET
In the COM-based model, you must loop through all the fields in the fields collection for the profile object, explicitly checking to see if 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
ProfileProperty.Attributes

Retrieving site term names

ASP ASP.NET
In the COM-based model, you retrieve the list of all the site terms using the GetSiteTerms method on the BizDataAdmin object, and then parse through the returned XML stream for the site term names. In the .NET-based model, you can easily retrieve the site terms through the ProfileContext.SiteTermNames property.

Retrieving site terms

ASP ASP.NET
In the COM-based model, you retrieve the list of all the site terms using the GetSiteTerms method on the BizDataAdmin object, and then parse through the returned XML stream for the site term. In the .NET-based model, you can easily retrieve the site term through the ProfileContext.GetSiteTerm method.

Accessing Commerce OLE DB Provider (CSOLEDB)

ASP ASP.NET
Application(“MSCSAdoConnection”) ProfileContext.CommerceOleDbProvider

Executing queries through the Commerce OLE DB Provider

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

Copyright © 2005 Microsoft Corporation.
All rights reserved.