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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:37:02+00:00 2026-05-26T06:37:02+00:00

I currently am using existing code that has Sql.Append(UPDATE Store SET + LogoAlign=’ +

  • 0

I currently am using existing code that has

Sql.Append("UPDATE Store SET" +
"LogoAlign='" + (String.Compare(drpLogoAlign.SelectedValue, String.Empty) == 0 ? "NULL" : "'" + drpLogoAlign.SelectedValue + "'") +
"', Height='" + DB.QuerySafeDisplayHTML(txtHeight.Text.ToString()) +
"', Width='" + DB.QuerySafeDisplayHTML(txtWidth.Text.ToString()) +

and it goes on like that for all the columns in the table that it is updating. I would like to know if it would be better using LINQ, easier, more beneficial, and if so how would I go about doing it?

Thanks

  • 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-26T06:37:03+00:00Added an answer on May 26, 2026 at 6:37 am

    For Linq To Entity you can just get all the Store than loop through them to change the value and use the Entity to SaveChanges.

    For example:

    using (TestDBEntities ctx = new TestDBEntities())
    {
        var allStore = ctx.Stores;
        foreach(var store in allStore)
        {
            store.LogoAlign = (String.Compare(drpLogoAlign.SelectedValue, String.Empty) == 0 ? "NULL" : "'" + drpLogoAlign.SelectedValue + "'");
            store.Height = txtHeight.Text.ToString();
        }
        ctx.SaveChanges();
    }
    

    You can do the same with Linq To Sql with the DataContext.

    using (TestDataContext ctx = new TestDataContext())
    {
        var allStore = ctx.Stores;
        foreach(var store in allStore)
        {
            store.LogoAlign = (String.Compare(drpLogoAlign.SelectedValue, String.Empty) == 0 ? "NULL" : "'" + drpLogoAlign.SelectedValue + "'");
            store.Height = txtHeight.Text.ToString();
        }
        ctx.SubmitChanges();
    }
    

    But, if you want to be more performance, I think it should be in a stored procedure, this way you won’t need to get all the data before updating.

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

Sidebar

Related Questions

We currently have a 10 year old nasty, spaghetti-code-style SQL Server database that we
Currently I am working on an existing website that was initially created using SMF
I currently have an existing database and I am using the LINQtoSQL generator tool
I have a lot of legacy code which I currently compile using an antiquated
I have an existing site that has a bunch of different models and controllers.
We have a database that has been deployed to various clients. We are currently
I'm currently refactoring an existing DAL which has a facade the user calls and
I'm currently working on a legacy eCommerce system front-end that has alot of duplicate
We currently have an existing ASP.NET application that we want to migrate to DNN.
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. 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.