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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:28:31+00:00 2026-06-06T21:28:31+00:00

I try to change a SQL Delete command into LINQ. this is my SQL

  • 0

I try to change a SQL Delete command into LINQ. this is my SQL Command:

DELETE FROM [TrackPoints]
WHERE [RouteFK] IN (SELECT RouteId
                    FROM Routes
                    WHERE UserId = @UserId)

and this is the LINQ code that I’ve written:

int UID =1;
FirstDataContext aspnetdb = new FirstDataContext();
var res1 = from q1 in aspnetdb.Routes
           where q1.UserId == UID
           select q1.RouteId;
foreach (var k in res1)
{
    var eigen = from p in aspnetdb.Trackpoints
                where p.RouteFK == k
                select p.TrackPointId;

    aspnetdb.Trackpoints.DeleteOnSubmit(eigen.First());
    aspnetdb.SubmitChanges();
}

but in this line I have an error:

aspnetdb.Trackpoints.DeleteOnSubmit(eigen.First());

that said:

The best overloaded method match for ‘System.Data.Linq.Table.DeleteOnSubmit(LINQ_Test.Trackpoint)’ has some invalid arguments

What should I do?

  • 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-06T21:28:34+00:00Added an answer on June 6, 2026 at 9:28 pm

    Use this:

    var eigen = (from p in aspnetdb.Trackpoints
                where p.RouteFK == k
                select p).First();
    

    or what is shorter:

    var eigen = aspnetdb.Trackpoints.First(p => p.RouteFK == k);
    

    because it returns Trackpoint

    While your select p.TrackPointId returns Int.


    var r = from r in aspnetdb.Routes
            join p in aspnetdb.Trackpoints on p.RouteId equals r.RouteFK
            where r.UserId == UID
            select p;
    
    foreach (var x in r)
    {
        aspnetdb.Trackpoints.DeleteOnSubmit(x);
    }
    aspnetdb.SubmitChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to change this columns list: Nombre Imagen Descripcion Activo IdLineaProducto into
I try to change my code from MYSQL to SQL Server. I have some
When I try to change the default collation of a SQL Server instance using
I try to limit resultset in size without having to change each SQL statement
I try to change a string into an object using eval but failed. var
I try to change the color from a UIPopoverControler on iOS 5. To do
I try to change the dimensions of the view in interface builder from the
I try to change over htaccess from http://www.mydomain.com/pictures/generated/product/1/280_280_75/nopic.jpg to http://www.mydomain.com/pictures/generated/product/1/280_280_75/nopic1.jpg Here is my rules
example i try to change cell.accessoryView from picture1 to picture2 by fadein but my
Being new to Linq-to-SQL, I ran into one of it's Gotchas today and 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.