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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:57:04+00:00 2026-05-21T06:57:04+00:00

I have a LINQ2SQL Query: //Pulling the Product_ID from the PlanMaster Table from WebEnroll

  • 0

I have a LINQ2SQL Query:

 //Pulling the Product_ID from the PlanMaster Table from WebEnroll DB!
                var tr = from s in dt.PlanMasters
                         where s.PlanName == productName
                         select new
                         {
                             s.Product_ID
                         };

This is pulling Product_ID which is working good. Now I want to ADD a record into another LINQ statement which is here:

                CommissionsV2DataContext cv = new CommissionsV2DataContext();
                Entity_Product_Point ev = new Entity_Product_Point();
                ev.Entity_ID = getEntity;
                ev.Product_ID = tr.; ?????

I want to store the variable which I am getting from tr (that is Product_ID) to ev.Product_ID.

How should I convert an object to an INT? Thank you!

  • 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-21T06:57:05+00:00Added an answer on May 21, 2026 at 6:57 am

    The problem is that your first query returns a collection of objects with an integer property, not a single integer. You can change your query to this instead:

    var tr = (
        from s in dt.PlanMasters
        where s.PlanName == productName
        select s.Product_ID).First();
    

    Or, more cleanly, IMO:

    var tr = dt.PlanMasters.First(s => s.PlanName == productName).Product_ID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Linq2Sql query that looks like this: var data = from d
I have two classes generated by LINQ2SQL both from the same table so they
I have a query in linqtosql that returns a LabelNumber: var q = from
I have a case where I have a linq2sql dbml with 2 table in
I have a table in my LINQ2SQL diagram with a column called DayOfWeek in
I have to concat 2 linq2sql query and I have an issue since the
I have currently moved my blogengine over from Linq2Sql to NHIbernate. I'm stuck at
I have written quite a bit of code which uses the Linq2Sql table relationships
I have a bit complex linq2sql query, it doesn't contain any 'order by' statements,
Is it possible to cancel a linq2sql query? Like if I have built a

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.