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

  • Home
  • SEARCH
  • 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 4088670
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:00:44+00:00 2026-05-20T19:00:44+00:00

I am using linq to sql and I have 2 tables(sedan, suv: they are

  • 0

I am using linq to sql and I have 2 tables(sedan, suv: they are all same except suv has a height column, everything else is same ) but since they are in different tables and pregenerated classes I have a lot of ifs in my functions.Depending on enum car type I manupulate one or the other. I want to get rid of ifs, how should I design the database or how can I achive eliminating ifs ? like can I use generics?

  • 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-20T19:00:45+00:00Added an answer on May 20, 2026 at 7:00 pm

    I would use the same table, but have a nullable height column (mapped to a nullable type in C#). Use another column, say type, to encode the vehicle type (you can use this as a discriminator for your classes). Use a constraint so that when the discriminator shows it is an SUV, the height column is required to be non-null.

    Now map the table onto an abstract Car class with subclasses of SUV and Sedan, discriminated by the type column. I’d probably make the height property protected in the Car class and then add a public property in the SUV class that exposes the height property (basically using it as a backing field).

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

Sidebar

Related Questions

I'm using Linq to SQL and some of my tables don't have primary keys:
I'm using Linq-To-SQL for a project with around 75 tables. We have to keep
I have a table in the database that I'm retrieving using LINQ to SQL,
Using LINQ to SQL, I have an Order class with a collection of OrderDetails.
I have started using Linq to SQL in a (bit DDD like) system which
I have been using LINQ to SQL for a while, and there is one
I'm using LINQ to SQL and C#. I have two LINQ classes: User and
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it
Iam using linq to SQl, And I have some Serilization problem, For Example I

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.