Duplicate Address checking script

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anos atrás
The AddAddress method checks for existing postal addresses by passing an Address object into the .Contains method.

Am I right in thinging that the statement
if (!this.Addresses.Contains(address))
will never be
True 
as the "address" object has a
CreatedOnUtc
property that will always be different?

public virtual void AddAddress(Address address)
        {
            if (!this.Addresses.Contains(address))
                this.Addresses.Add(address);
        }


Or am I confused?

Darren
12 anos atrás
No, the Address entity inherits from BaseEntity which overrides the Equals method.  Basically it will determine equality based on the Id property.
12 anos atrás
AndyMcKenna wrote:
No, the Address entity inherits from BaseEntity which overrides the Equals method.  Basically it will determine equality based on the Id property.


Doesn't that defeat the object? Surely the statements purpose is to check for addresses with exactly the same string properties as one already existing for that customer.

Or am I missing something?

Thanks for your response by the way.

Darren
12 anos atrás
Can anyone suggest how I can check to see if an address (same strings in each field) already exists for a customer?

Darren
12 anos atrás
Customer entity has Addresses property. You can use FindAddress(...) extension method in order to find an address with the same properties (same strings in each field)
12 anos atrás
a.m. wrote:
Customer entity has Addresses property. You can use FindAddress(...) extension method in order to find an address with the same properties (same strings in each field)


Brilliant. Thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.