c# - Overriding Equals on IEquatable -
I have the following method that I use to prevent people from changing querystring
in order Trying to see the details of other people:
Public Static Bull. Person repository repo = new person repository (); Wessel Reptiles Ship Repos = New Ship Repository (); Person current nature = repo Getparsenbyuser (current user); Int qs = int.Parse (request.QueryString ["VesselId"]); Ship CurrentWell = Ship Reps Gateswest (QS); If (! String.IsNullOrEmpty (request.QueryString ["VesselId"])) {if (IsCurrentUserAdmin ()) {return true; // always return true to the administrator} and {if (current Person.Vessels.Contains (Current Vessel)) {return true; } And false return; True} true; }
For example, I am currently debugging currentPerson.Vessels
<3> a Icollection & lt; Vasel & gt; Out of 3 ships produced;
VesselId
which is the Weissel ID of currentVessel
but the match is failing and returning the method false
.
I have read some of the same questions and MSDN documentation and I understand what is happening here, because the letter whose ID has an ID of 6 within its eclipse, There is a different example of the current Weissel, which I am trying to match, the result is not equal to the result and something similar with the equality rules are not based on the ID.
In the I want my own custom rules based on ID for equality in this example. How can I override this method? Overriding person
model public virtual Ilkonak & lt; Vessel & gt; Vessels {receive; Set; }
This means that I have to apply the IEquatable
interface to my vessel / <> code and then override the equal method.
equal
in this state is slightly higher, just Why not
currentPerson.Vessels.Any (x => x.id == currentVessel.ID)
Comments
Post a Comment