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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:27:16+00:00 2026-05-12T00:27:16+00:00

I have a unique requirement that I hope is possible with LINQ to SQL.

  • 0

I have a unique requirement that I hope is possible with LINQ to SQL.

First off, I am extending an older application so I am stuck with current database column names and the existing LINQ entity classes.

I have a LINQ wrapper with the following method:

public T Get(int id) where T : class, IEntity {
  ...
}

IEntity looks like:

public interface IEntity {
  int Id { get; }
}

My existing entity class (generated by LINQ) looks like:

//this is not the exact code
//it is just to give you an idea
public parital class Widget {
  public int WidgetId { get; set; }
  public string WidgetName { get; set; }
}

So in order to make Widget work with my wrapper I extended it to be an IEntity like:

public partial class Widget : IEntity {
  public int Id { get { return WidgetId; } }
}

When I do a select like:

Repository<Widget>.Get(123);

I get an error saying Id is not mapped in SQL.

What I want to know is there a way for me to make Widget an IEntity and use Id as an alias of WidgetId. There is already a lot of older code written (without the repository wrapper) that references WidgetId so I don’t want to have to change this.

All suggestions are appreciated. Am I going about this wrong?

  • 1 1 Answer
  • 4 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-12T00:27:16+00:00Added an answer on May 12, 2026 at 12:27 am

    LINQ doesn’t know to translate Id to WidgetId.

    In the O/R designer you can rename the columns to whatever you need them to be. When you do this, LINQ will be able to properly translate the column names. Renaming them in the O/R designer doesn’t affect the database at all, so it is a perfectly safe operation. You can open the .designer.cs file and see how the Attributes are used to map column names to class properties.

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

Sidebar

Related Questions

I have an SQL database with a set of tables that have Unique Id's.
I'm wondering if it is possible to have unique characters that cannot be seen
I have a web application that has a requirement to take data from an
The requirement I have is that part of the install process for an application
In my db application I have a requirement for a unique, 4-digit number field
Using SQL Server 2008, I have a requirement that email addresses in my user
I have a unique requirement which I need to meet to with sitecore, and
I know that using the following codes will make each column have unique values,
I have a unique industrial application where I do not want the Windows CE
I have a unique situation where I'm building a site that will call data

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.