Skip to content

Codepolice

  • ⤫

LINQ to SQL and the XML datatype

Posted by Judy Alvarez Posted on February 25, 2022March 3, 2022
0

Today i have done some stuff with LINQ to SQL and the xml data type from SQL Server 2005. I had some problem finding information about this and spent some hours figuring out how the insert/update/delete worked. Post a comment if you find something I’ve done wrong. This is mostly for my own reference.

Get data

var q = (from ec in Business.PostCalc. ExtraCompensation.Descendants(“compensation”)select new { id = ec.Attribute(“id”).Value,  code = ec.Element(“code”).Value,  amount = ec.Element(“amount”).Value,  description = ec.Element(“description”).Value }).ToList(); lwExtraCompensation.DataSource = q;lwExtraCompensation.DataBind();

Delete data

You should of course run SubmitChanges and so on in some method. I do this way so that we can save everything at once later.

XElement ec = Business.PostCalc.ExtraCompensation;XElement newExtraComp= new XElement(ec); newExtraComp.DescendantsAndSelf(“compensation”).Where(x => x.Attribute(“id”).Value.ToString() == e.CommandArgument.ToString()).First().Remove(); Business.PostCalc.ExtraCompensation = newExtraComp; txtDescription.Text = “”;txtAmount.Text = “”;txtCode.Text = “”; PostCalculationChanged(this, new EventArgs());

Update data

XElement ec = Business.PostCalc.ExtraCompensation; XElement newExtraCompensation = new XElement(ec); newExtraCompensation.Add(new XElement(“compensation”,new XElement(“description”, txtDescription.Text),new XElement(“amount”, txtAmount.Text),new XElement(“code”, txtCode.Text),new XAttribute(“id”, Guid.NewGuid()))); Business.PostCalc.ExtraCompensation = newExtraCompensation; txtDescription.Text = “”;txtAmount.Text = “”;txtCode.Text = “”; PostCalculationChanged(this, new EventArgs());
Categories: JavascriptTagged: asp net core cookie authentication, validation in asp net

Post navigation

Next Next post: LINQ to SQL and the XML datatype

Related Posts

  • Bringing Python apps into Node

    #​596 — October 14, 2025 Read on the Web 📂 A Modern Guide to Reading and Writing Files in Node — A comprehensive guide to various methods for working with files, from promise-based methods through to working with streams, processing files concurrently, using file handles, and memory-efficient techniques. Luciano Mammino A Way to Integrate Python ASGI with Node.js

    Posted by Posted on October 14, 2025
    0
  • Vite gets its own documentary

    #​756 — October 10, 2025 Read on the Web JavaScript Weekly ▶  Vite: The Documentary — From the same creators of the fantastic ▶️ Node.js, ▶️ Angular and ▶️ React documentaries comes an up to date look at Vite, the build tool that has taken the JavaScript ecosystem by storm in recent years. Many luminaries make an appearance to

    Posted by Posted on October 10, 2025
    0
  • npm security best practices to consider

    #​595 — October 7, 2025 Read on the Web 15 Recent Node Features That Can Replace Popular npm Packages — Many features that once required third-party packages are now built into the runtime itself. Here’s a look at some of the most notable that you may want to experiment with, prior to reducing unnecessary dependencies. Lizz

    Posted by Posted on October 7, 2025
    0
  • React 19.2 is in the building

    #​755 — October 3, 2025 Read on the Web JavaScript Weekly The State of JavaScript 2025 Survey — Each year, Devographics runs an epic survey of as many JavaScript community members as it can and turns the results into an interesting report on the state of the ecosystem – here’s the results from 2024. If

    Posted by Posted on October 3, 2025
    0
  • Using Node with Cloudflare Workers

    #​594 — September 30, 2025 Read on the Web 🗓️ We’re back after taking a week off for my birthday. I’ve never bothered to do that before, but I figured I’d give it a go, and.. it was good 😅 We’re now back every week until Christmas!__Peter Cooper, your editor A Year of Improving Node.js

    Posted by Posted on September 30, 2025
    0
  • The first browser with JavaScript landed 30 years ago

    #​754 — September 26, 2025 Read on the Web JavaScript Weekly Give Your AI Eyes: Introducing Chrome DevTools MCP — The Chrome team has released an MCP server for Chrome DevTools, enabling agents like Claude Code or OpenAI Codex to use the DevTools to debug and analyze the performance and behavior of your webapps (or

    Posted by Posted on September 26, 2025
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • Bringing Python apps into Node
  • Vite gets its own documentary
  • npm security best practices to consider
  • React 19.2 is in the building
  • Using Node with Cloudflare Workers
https://flatlogic.com/generator
COPYRIGHT © 2025 - Codepolice