Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7053773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:32:45+00:00 2026-05-28T03:32:45+00:00

I am using the FluentValidation framework in C# which has the following two method

  • 0

I am using the FluentValidation framework in C# which has the following two method overloads:

IRuleBuilder<TObject, TProperty>
    IRuleBuilderOptions<TObject, TProperty> Equal(TProperty toCompare, [IEqualityComparer comparer = null])
    IRuleBuilderOptions<TObject, TProperty> Equal(Expression<Func<TObject,TProperty>> expression, [IEqualityComparer comparer = null])

Basically one of the overloads lets you pass in an actual TProperty to compare, and the other lets you do a lambda that returns a TProperty from a TObject.

When I do the following it works:

RuleFor(r => r.First).Equals(r => r.Second);

It is getting the right overload in this case. When I try and pass in a value for the comparer it defaults to the other overload:

RuleFor(r => r.First).Equals(r => r.Second, new ObjectComparer()); // will not compile

This will not compile because it thinks I’m trying to use the first overload.

Is there a way I can force C# to use the second overload?

Edit:

ObjectComparer is an IEqualityComparer:

public class ObjectComparer : IEqualityComparer<MyClass>
{
     // ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:32:46+00:00Added an answer on May 28, 2026 at 3:32 am

    IEqualityComparer<T> does not inherit IEqualityComparer and therefore your class does not implement IEqualityComparer! Implement both of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following the article http://www.thekip.nl/2011/09/22/using-fluentvalidation-for-both-domain-validation-and-validation-in-mvc-projects/ for me it's not still clear where does the validation
I am using FluentValidation in my MVC project and have the following model and
I'm using FluentValidation framework. And at the moment I have several validators (per entity).
Using C#, I need a class called User that has a username, password, active
Using the following as an example (with $db being a previously created database connection
Using C++ preprocessor directives, is it possible to test if a preprocessor symbol has
Using the following database table structure: Order Table: OrderId OrderName OrderItem Table: OrderId ItemId
Using FluentValidation, is it possible to throw an exception on a single rule failure?
I am using FluentValidation in my application to verify my entities, but I have
In which circumstances would you choose FluentValidation (FV) over the ASP.NET MVC 3 way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.