I'm attempting to make use of the
.Contains
function on a list of custom objectsThis is definitely the list:
And the
CartProduct
:Since upgrading to 19.14 all MYOB email for Payroll and Supplier with PDF attachements are showing This Item contains active content. Open the item to read its contents. Most of our staff and suppliers are unable to open the attachment. To see if Firefox has blocked parts of the page that are not secure, click the green lock icon. For more information, see the Unblock mixed content section, below. Mixed content is not blocked: not secure: If you see a lock with a red line over it, the page contains mixed active content and Firefox is not blocking insecure elements.
Therefore i try to discover a very similar cartproduct within the checklist:
But it ignores equivalent cartproducts and we wear't seem to know what it bank checks on - the Identification? or it all?
Thanks a lot in progress! :)
James3,00733 money badges2828 gold badges4444 bronze badges
January JohansenJan Johansen1,05955 yellow metal badges2323 gold badges4141 bronze badges
6 Solutions
You need to apply
IEquatable
or overrideEquals
andGetHashCode
For instance:
Rowland ShawRowland Shaw
33k1212 yellow metal badges8383 sterling silver badges150150 bronze badges
If you are using.Internet 3.5 or newer you can use LINQ expansion strategies to attain a 'contains' check out with the
Any
extension method:This will examine for the life of a item within
CartProducts
which provides an Identification coordinating the Identity ofp
. You can put any boolean appearance after the=gt;
to carry out the check out on.This also offers the benefit of working for LINQ-to-SQL inquiries as nicely as in-memory inquiries, where
John TurnerJohn TurnerContains
doesn'testosterone levels.26.4k1212 silver badges8080 metallic badges146146 bronze badges
It checks to observe whether the specific object is included in the listing.
You might be better using the Find technique on the checklist.
Here's an illustration
Hope that assists
You should also look at LinQ - overkill for this possibly, but a useful tool nonetheless.
Martin MilanMartin Milan5,39511 magic badge2626 metallic badges4040 bronze badges
By default reference point types possess reference equality (i.e. two instances are just identical if they are usually the same item).
You require to override
RichardRichardItem.Means
(andItem.GetHashCode
to match) to apply your own equality. (And it is usually then good practice to apply an equal rights, , user.)91.5k1818 precious metal badges166166 silver badges224224 bronze badges
If you need to have handle over this you require to carry out the IEquatable user interface1
1: http://This method determines equal rights by using the default equal rights comparer, as defined by the object's execution of the IEquatable.Equals method for T (the type of ideals in the listing).
Gerrie SchenckGerrie Schenck17.5k1717 money badges6161 magic badges9595 bronze badges
Carry out
override Means
andGetHashCode
utilized:
A new. MorelA new. Morel