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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:44:36+00:00 2026-06-05T02:44:36+00:00

I need a ColumnName of a table in EF which I have it’s ID.

  • 0

I need a ColumnName of a table in EF which I have it’s ID.
My Tables are something like this :

Retailers

[RetailerId] [int] IDENTITY(1,1) NOT NULL,
[RetailerName] [varchar](50) NOT NULL,
[StateName1] [bit] NOT NULL,
[StateName2] [bit] NOT NULL,
[StateName3] [bit] NOT NULL,

States

   [SId] [int] IDENTITY(1,1) NOT NULL,
   [StateName] [varchar](50) Not Null

I receive an SId from a function and need to select all retailers which are located in that State.
Something like:

var listOfRetailers = (from m in db.Retailers where m.[a column that it's id is equal to SId] == true select m ).toList();
  • 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-06-05T02:44:37+00:00Added an answer on June 5, 2026 at 2:44 am

    From your comments I think this is what you are looking for. But design wise what you have done is bad. I will explain shortly.

    var listOfRetailers;
    if(SId == 1)
    {
    listOfRetailers = db.Retailers.select(r=> r.StateName1.Equals(true)).ToList();
    }
    else if(SId == 2)
    {
    listOfRetailers  = db.Retailers.select(r=> r.StateName2.Equals(true)).ToList();
    }
    else if(SId == 3)
    {
    listOfRetailers  = db.Retailers.select(r=> r.StateName3.Equals(true)).ToList();
    }
    

    EDIT

    Technically this is a bad design. Coz you are making the assumption that your States table will have 3 records

    1 - ACT
    2 - NSW
    3 - NT
    

    For every state you are have a corresponding column in Retailers table StateName1, StateName2, StateName3

    Lets say you want to introduce a 4th state (say 4 - VIC). Now you will need to introduce a new column called StateName4 in your Retailers table. (by doing this there will be code level and DB level changes)

    Also with the new columns you are introducing additional overheard of unused/ redundant data.

    since this is a many-to-many situation (one state can have many retailers and one retailer can be in many states), the best approach would be to create
    3 tables (Retailer, State, RetailerState), where by RetailerState table will play the role of mapping entries from State, Retailer tables

    Retailer
    ---------
    [RetailerId] 
    [RetailerName]
    
    State
    ------
    [SId] 
    [StateName]
    
    RetailerState
    --------------
    [RetailerId] 
    [SId] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table array which looks like this: tablearray = [ {'column1': 1,
I have a mysql table that looks something like this: id | col_1 |
I have a div in which i dynamically add different tables. I need to
I have two tables, users and images which need to be joined. there is
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
Need help with a query that I wrote: I have three tables Company id
I have a huge query which uses case/when often. Now I have this SQL
I have a database name "CUED" (sqlite Android)it have a table HELLO which contain
I have the following macro which needs to loop though an Excel-2007 table. The
Given a table like this: [Last Name] [First Name] [DepartmentID] --------------------------------------- Doe John 1

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.