-1

I have a column in one of my SQL tables that is of type XML. I want to insert an entire XML file into one of the cells of this column from the back-end using linq. There are a few similar questions to this, but none of them have been much help to me.

Thanks in advance.

EDIT:

Well I really haven't made it very far, but here is a rough idea of what I'm trying to do.

StagingDBDataContext ctx = new LoaderCommon.StagingDBDataContext();
upload_info ups = (from u in ctx.upload_infos where u.upload_id == info.upload_id select u).SingleOrDefault();
ups.upload_params = //xml text (huge file, 50,000 lines long)
Nick Nicolini
  • 129
  • 1
  • 3
  • 14
  • 5
    Can you post some code of what you have tried? – TheGeekYouNeed Jul 23 '12 at 21:22
  • 1
    This is code to retrieve the XML. What about inserting it? Where does the XML you need to enter into the database come from? – TheGeekYouNeed Jul 23 '12 at 21:55
  • I have an xml file on my computer that has all of the data in it already. So I have a directory, I just need to import it into sql. Btw, upload_params is the XML column, so I need to set that to the XML text. – Nick Nicolini Jul 23 '12 at 21:58

1 Answers1

1

When you put it on SqlXml just read xml as string

private string LoadXml(string FileName)
{
    try
    {
        using (StreamReader reader = new StreamReader(FileName))
        {
            return reader.ReadToEnd();
        }
    }
    catch
    {
        return string.Empty;
    }
}