LINQ dataContext reports wrong parameter type?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

    LINQ dataContext reports wrong parameter type?

    Hi...

    I have an sql server 2005 database that has a table called TestXml in it.
    The table has the columns ID (identity, int) and MyXml(xml). I created a
    stored proc on the server to insert a row into the table. It looks like
    this:

    create procedure InsertRow(@xmlD ocument xml)
    as
    insert into TestXml values(@xmlDocu ment);

    I created a new linq class by adding (in vs2008) a linq classes file and
    called it TestXml.dbml. I opened the o/r designer and drug the TestXml table
    from server explorer onto the designer. I then drug the stored proc listed
    above from server explorer onto the designer. When it was listed in the
    methods list, it had this for the signature:
    InsertRow(Syste m.Xml.Linq.XEle ment XmlDocument). I didn't want the intput
    paramater to be an XElement since I haven't ever heard of it before. It was
    supposed to be an XmlDocument object being inserted instead. Any ideas why
    this happened? Do I need to convert all of my XmlDocuments to Xelements now?



  • Martin Honnen

    #2
    Re: LINQ dataContext reports wrong parameter type?

    Andy B wrote:
    I have an sql server 2005 database that has a table called TestXml in it.
    The table has the columns ID (identity, int) and MyXml(xml). I created a
    stored proc on the server to insert a row into the table. It looks like
    this:
    >
    create procedure InsertRow(@xmlD ocument xml)
    as
    insert into TestXml values(@xmlDocu ment);
    >
    I created a new linq class by adding (in vs2008) a linq classes file and
    called it TestXml.dbml. I opened the o/r designer and drug the TestXml table
    from server explorer onto the designer. I then drug the stored proc listed
    above from server explorer onto the designer. When it was listed in the
    methods list, it had this for the signature:
    InsertRow(Syste m.Xml.Linq.XEle ment XmlDocument). I didn't want the intput
    paramater to be an XElement since I haven't ever heard of it before. It was
    supposed to be an XmlDocument object being inserted instead. Any ideas why
    this happened? Do I need to convert all of my XmlDocuments to Xelements now?
    LINQ to SQL maps xml columns to the System.Xml.Linq .XElement, that is
    correct. XElement is documented here:
    <URL:http://msdn2.microsoft .com/en-us/library/System.Xml.Linq .XElement.aspx>
    respectively the general LINQ to XML documentation is here:
    <http://msdn2.microsoft .com/en-us/library/bb387098.aspx>

    Why do you think that it should be System.Xml.XmlD ocument? I think it
    was System.Xml.Linq .XDocument for a while but that was changed:
    <URL:http://forums.microsof t.com/MSDN/ShowPost.aspx?P ostID=2170562&S iteID=1>

    --

    Martin Honnen --- MVP XML

    Comment

    • Andy B

      #3
      Re: LINQ dataContext reports wrong parameter type?

      Not saying it "has to be" XmlDocument. Just got me off guard is all. Used to
      seeing auto generators like o/r designer mapping to the same dataTypes (like
      in a dataSet). Well, now that I think about it, maybe linq is more right
      when it says the input parameter should be Xelement (it's closer than what a
      dataSet would do with just string).


      "Martin Honnen" <mahotrash@yaho o.dewrote in message
      news:%236FbWVUo IHA.4716@TK2MSF TNGP06.phx.gbl. ..
      Andy B wrote:
      >
      >I have an sql server 2005 database that has a table called TestXml in it.
      >The table has the columns ID (identity, int) and MyXml(xml). I created a
      >stored proc on the server to insert a row into the table. It looks like
      >this:
      >>
      >create procedure InsertRow(@xmlD ocument xml)
      >as
      >insert into TestXml values(@xmlDocu ment);
      >>
      >I created a new linq class by adding (in vs2008) a linq classes file and
      >called it TestXml.dbml. I opened the o/r designer and drug the TestXml
      >table from server explorer onto the designer. I then drug the stored proc
      >listed above from server explorer onto the designer. When it was listed
      >in the methods list, it had this for the signature:
      >InsertRow(Syst em.Xml.Linq.XEl ement XmlDocument). I didn't want the intput
      >paramater to be an XElement since I haven't ever heard of it before. It
      >was supposed to be an XmlDocument object being inserted instead. Any
      >ideas why this happened? Do I need to convert all of my XmlDocuments to
      >Xelements now?
      >
      LINQ to SQL maps xml columns to the System.Xml.Linq .XElement, that is
      correct. XElement is documented here:
      <URL:http://msdn2.microsoft .com/en-us/library/System.Xml.Linq .XElement.aspx>
      respectively the general LINQ to XML documentation is here:
      <http://msdn2.microsoft .com/en-us/library/bb387098.aspx>
      >
      Why do you think that it should be System.Xml.XmlD ocument? I think it was
      System.Xml.Linq .XDocument for a while but that was changed:
      <URL:http://forums.microsof t.com/MSDN/ShowPost.aspx?P ostID=2170562&S iteID=1>
      >
      --
      >
      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/

      Comment

      Working...