Try our conversational search powered by Generative AI!

Customer Billing Address in SQL Query

Vote:
 

This question is related to "EPiServer Commerce 1 R2 SP1".

I want to list customers and their billingAddress (in our system you can only have one billing address). We dont use the preferedBillingAddress property.

In the API you there is a AddressType of type enum CustomerAddressTypeEnum on each address object (of type CustomerAddress). But in the cls_Address table in the database the AddressType column is of type uniqueidentifier (and therefore unique). I really cannot discover the relationship between the guid and enum (enum has 3 values), and i cannot find any other column that could hold the information.

I just want to:

SELECT
*
FROM cls_Address
WHERE AddressType = enumVALUE(billing = 4)

#80828
Feb 03, 2014 14:02
Vote:
 

In the cls_address table, the AddressType field is a key to the enum lookup table.
The following query will return all billing adresses;

SELECT a.AddressId
,a.Email
,a.ContactId
,e.TypeName
,e.Id
,m.FriendlyName
FROM cls_Address a
INNER JOIN mcmd_SelectedEnumValue e ON a.AddressType = e.[Key]
INNER JOIN mcmd_MetaEnum m ON m.TypeName = e.TypeName AND m.Id = e.Id
WHERE m.FriendlyName = 'Billing'

#81066
Feb 07, 2014 23:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.