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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:13:33+00:00 2026-06-19T04:13:33+00:00

im trying to add a single row to a class using linq to sql.

  • 0

im trying to add a single row to a class using linq to sql.
i have a table (AdressesTable) wich contains a key named ID and an adress1 and adress2 column…

i created a class:

public class Adresses
{
public int ID { get; set; }
public int adress1 { get; set; }
public int adress2 { get; set; }
}

i created a datacontext and wrote a query

DBDataContext db = new DBDataContext();

Adresses adr = (from p in db.AdressesTable 
    where p.ID ==1 
    select p).First();

but it’s not working… how can i add a sql query result to a class object?

  • 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-19T04:13:34+00:00Added an answer on June 19, 2026 at 4:13 am

    You need to build a DbContext like this:

    public class MyDbContext : DbContext
    {
        public DbSet<Addresses> Addresses { get; set; }
    }
    

    and then you can use it like this:

    var db = new MyDbContext();
    var adr = (from p in db.Addresses
        where p.ID == 1
        select p).First();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add multiple elements in a single row within a div. However,
I'm trying to INNER JOIN a single row from a table. The query returns
I am trying to add a row to a tableView using the following code.
I'm trying to add multiple jQuery data entries to a single element. I suspected
I'm trying to add a new nova-compute node (KUubuntu 12.04) to my single node
Im new to asp.net mvc. I'm trying add new model class but it got
Ok I am trying to dynamically add new rows to a already rendered table
I have a table with multiple tbody's, each of which has a classed row,
I am trying to update a table in my database with another row from
I'm trying to add rows dynamically to a System.Web.UI.WebControls.Table control in ASP.NET. I found

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.