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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:13:30+00:00 2026-06-07T18:13:30+00:00

Taking advantage of Linq trying to make a neater update code on the provided

  • 0

Taking advantage of Linq trying to make a neater update code on the provided DataSet-Based approach :

The Code I’m trying is :

                ListProducts.ForEach( product =>
                {
                    DsProducts.TblProductsRow row = Ds1Products.TblProducts.First( p => p.Name == product.Name);
                    row.Price = Product.Price ;
                });

                Adapter.Update(Ds1Products, "TblProducts"); 

Not sure weather I needed parameters here or not, I haven’t defined any yet.
Cause wanted to use the "Typed" facilities of it.
The Data Adapter is initialized and filled.

Notes :

  1. It does not work right now , Gotten Error here : "Sequence contains no matching element"

  2. Wanted to Replace the foreach with Linq's Select if possible

    ( Try it to be neat and Linqy as possible )

  3. its in SQL CE (Shouldn’t be a problem here on most cases)

  • 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-07T18:13:31+00:00Added an answer on June 7, 2026 at 6:13 pm

    This is hopefully what you need:

    var productRows = from p in ListProducts
                      join row in Ds1Products.Tables["TblProducts"].AsEnumerable()
                      on p.Name equals row.Field<String>("Name")
                      select new { NewPrice = p.Price, Row = row };
    foreach(var productInfo in productRows)
    {
        productInfo.Row.SetField<Double>("Price", productInfo.NewPrice);
    }
    

    Edit: Here’s the strong typed DataSet way(almost identical):

    var productRows = from p in ListProducts
                      join row in Ds1Products.TblProduct
                      on p.Name equals row.Name 
                      select new { NewPrice = p.Price, Row = row };
    foreach (var productInfo in productRows)
    {
        productInfo.Row.Price = productInfo.NewPrice;
    }
    Adapter.Update(Ds1Products, "TblProducts"); 
    

    By the way, List.ForEach is not Linq, it existed already in .NET 2.0 hence prior to Linq.

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

Sidebar

Related Questions

I'm trying to save myself some coding time by taking advantage of using namespace
When my android application native code runs on NEON processor I'm taking advantage of
I am trying to build a form in WordPress and taking advantage of all
I know LINQ can group by taking advantage of anonymous types, so I though
I am trying to create a cron job while taking advantage of my current
I am trying to create a WPF application taking advantage of Commands but I
Taking this file as an example, I'm trying to read the data in a
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
I'd like to implement a jabber client to connect to facebook but taking advantage
http://www.grails.org/1.3.1+Release+Notes Improved Query Caching The findAll query method now supports taking advantage of the

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.