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 6341309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:00:21+00:00 2026-05-24T20:00:21+00:00

In my scenario, I have two types of objects. A plan and a tier

  • 0

In my scenario, I have two types of objects. A plan and a tier. Each one shares certain values, while the tier has 3 additional values (Rate, Min, and Max).

I would like to make a generic method to conditionally evaluate whether or not the new object can be written to the database, based on the following conditions:

Creation:

  1. A tier: ((o1.Rate!=o2.Rate) || ((o1.Start!=o2.Start) && (o1.End!=o2.End))) && (MinVal && MaxVal)
  2. A tier or plan: (o1.Name!=o2.Name)
  3. A tier or plan: Only one can have (Active == true), the rest must be false.

Is it possible to create a generic method for something like this? If so, are there any examples of something like this? Or does anyone have suggestions?

thanks!

MORE:
So I have a list of objects, and I need to compare a newly created one with each other object in the database before I actually write it to the database.

  • 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-24T20:00:25+00:00Added an answer on May 24, 2026 at 8:00 pm

    In order for this to work, the generic method (or type) would need a constraint that allowed it to understand all of the individual properties you have listed (Rate, Date, MinVal, MaxValue, Start, and End).

    If all of the types which you are worried about derive from the same base class or interface, you don’t need generics – just build a method that takes two arguments of that base type.

    If, however, they don’t, again, generics will likely not be a good fit here – however, there is another option. You could use dynamic to effectively use these properties using runtime binding. Just realize that, if you pass an argument of a type without those properties, it will fail at runtime.

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

Sidebar

Related Questions

The scenario is I have two div s: one is where I select items
I have a very simple scenario, using NHibernate: one abstract base class animal; two
I often come across a scenario where I have two collections of objects (either
I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record
I have the following scenario: Two lists of different Types which happen to contain
Scenario I have two WCF Services combined in a single App.Config file. I can't
I have scenario, I have two update panels on the page (both have update
Scenario I have an TWO datbase tables of exactly the SAME STRUCTURE. The difference
Assume the following scenario. I have two files A.cpp and B.cpp in trunk. At
Scenario I have a windows forms application. I want to use two different WCF

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.