3 Replies - 5110 Views - Last Post: 06 June 2012 - 06:19 PM

#1 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Creating a new SQL database from XML using LINQ to SQL (in C#)

Posted 06 June 2012 - 05:43 PM

Has anyone ever done this? I've had a brief look around and couldn't find any examples in LINQ.

If someone has done this or knows it's not possible, I'd love to know before I waste too much time looking into it.

Thanks in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: Creating a new SQL database from XML using LINQ to SQL (in C#)

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9090
  • View blog
  • Posts: 34,142
  • Joined: 12-June 08

Re: Creating a new SQL database from XML using LINQ to SQL (in C#)

Posted 06 June 2012 - 05:47 PM

How about you explain a bit more on what you are asking to do. Are the table definitions in the XML and you want to create that in a MsSQL db, or what?
Was This Post Helpful? 0
  • +
  • -

#3 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: Creating a new SQL database from XML using LINQ to SQL (in C#)

Posted 06 June 2012 - 06:04 PM

To be a little more specific,

I have a web service which is supplying me a schema (portion below) and what I'm thinking is that instead of parsing the XML and building and holding it in a data structure (or in a file) I might be better off using the schema to create a full database.

The reason I'm specifically looking for LINQ solutions is that the database would be SQL CE (WP7) which does not allow T-SQL interaction, but only LINQ to SQL.

<return xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xlink="http://www.w3.org/1999/xlink">
  <service_response service="application_schema" request="schema" request_id="566556" session_id="565665">
    <schema>
      <database>
        <dataset internalName="data" externalName="DATA">
          <xsd:schema>
            <xsd:import namespace="xxxxxxxx" />
            <xsd:element name="gis.function_texts" gml:name="Function Texts" type="gml:gis.function_textsType" substitutionGroup="gml:_Feature" />
            <xsd:complexType name="gis.function_textsType">
              <xsd:complexContent>
                <xsd:extension base="gml:AbstractFeatureType">
                  <xsd:sequence>
                    <xsd:element name="text_1" sw:name="text_1" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_2" sw:name="text_2" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_3" sw:name="text_3" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_4" sw:name="text_4" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_5" sw:name="text_5" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_6" sw:name="text_6" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_7" sw:name="text_7" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_8" sw:name="text_8" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_9" sw:name="text_9" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_10" sw:name="text_10" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_11" sw:name="text_11" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_12" sw:name="text_12" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_13" sw:name="text_13" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_14" sw:name="text_14" minOccurs="0" type="gml:GeometryPropertyType" />
                    <xsd:element name="text_15" sw:name="text_15" minOccurs="0" type="gml:GeometryPropertyType" />
                  </xsd:sequence>
                </xsd:extension>
              </xsd:complexContent>
            </xsd:complexType>
          </xsd:schema>
        </dataset>
      </database>
    </schema>
  </service_response>
</return>


Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4468
  • View blog
  • Posts: 7,780
  • Joined: 08-June 10

Re: Creating a new SQL database from XML using LINQ to SQL (in C#)

Posted 06 June 2012 - 06:19 PM

This might help:

http://msdn.microsof...y/bb399420.aspx

It requires knowing the schema at compile-time, but it'll generate a DB on demand.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1