linq查询到数据表错误vb

时间:2015-05-16 16:30:33

标签: vb.net linq datatable dataset

我试图将linq查询的结果发送到新的数据表。然后,我将使用此数据表作为datagridview的数据源。目标是在datagridview中进行编辑,以返回到数据集,然后返回到xml。接下来,在这里:

msdn guide

使用此代码:

   Dim xmlFile As XmlReader
    xmlFile = XmlReader.Create(My.Settings.CfgFile, New XmlReaderSettings())
    Dim ds As New DataSet
    _XMLRawDS.ReadXml(xmlFile)

    Dim _XMLquery = From xmlsystem In _XMLRawDS.Tables("system").AsEnumerable()
        Join xmlcontroller In _XMLRawDS.Tables("controller").AsEnumerable() On xmlsystem.Item("system_Id") Equals xmlcontroller.Item("system_Id")
        Join xmlinput In _XMLRawDS.Tables("input").AsEnumerable() On xmlinput.Item("controller_Id") Equals xmlcontroller.Item("controller_Id")
        Join xmlport In _XMLRawDS.Tables("port").AsEnumerable() On xmlport.Item("input_Id") Equals xmlinput.Item("input_Id")
        Join xmlnewseq In _XMLRawDS.Tables("newseq").AsEnumerable() On xmlnewseq.Item("port_Id") Equals xmlport.Item("port_Id")
        Select New With
        {
            .input = xmlsystem.Field(Of String)("Input"),
            .name = xmlsystem.Field(Of String)("Name"),
            .id = xmlcontroller.Field(Of String)("id"),
            .type = xmlport.Field(Of String)("type"),
           .newseqtext = xmlnewseq.Field(Of String)("newseq_Text")
            }
    Dim _XMLCtrlsDT As DataTable = _XMLquery.copytodatatable()

但是,由于以下原因,最后一行不会编译:

'copytodatatable' is not a member of 'System.Collections.Generic.IEnumerable(Of <anonymous type>)'.

看起来和msdn一样对我来说,但确定有一些东西正在悄悄地工作..看看这个,但是如果我可以让它工作,我该死的。 ..

msdn-Implement CopyToDataTable Where the Generic Type T Is Not a DataRow

甚至不相信这个问题......

XML如下:

<!-- 
    Configuration Remap file
-->
<mameconfig version="10">
    <!-- 
    ############################################################
    Define controller aliases, This just makes the controller names
    a little easier to deal with for the rest of the file.
    ############################################################
    -->
    <controlleralias>
        <id>Ultimarc Ultra-Stik Player 1</id>
        <alias>U360 Player1</alias>
    </controlleralias>
    <controlleralias>
        <id>WingMan Extreme Digital 3D</id>
        <alias>Flightstick</alias>
    </controlleralias>
    <controlleralias>
        <id>HID#VID_061C_PID_AA00#7_35df86d5_0_0000#</id>
        <alias>Lightgun1</alias>
    </controlleralias>

    <!-- 
    ############################################################
    This is the System Default section
    It generally should be the FIRST system section in the cfg file
    ############################################################
    -->
    <system name="default">
        <!-- put a controller element here to have it copied into ONLY this particular
         system element
    -->
        <controller id="U360 Player1">
            <input>
                <port type="P1_JOYSTICK_UP">
                    <newseq type="standard">JOYCODE_YAXIS_UP_SWITCH</newseq>
                </port>
                <port type="P1_JOYSTICK_DOWN">
                    <newseq type="standard">
                        JOYCODE_YAXIS_DOWN_SWITCH
                    </newseq>
                </port>
            </input>
        </controller>
        <controller id="Flightstick">
            <input>
                <port type="P1_SELECT">
                    <newseq type="standard">JOYCODE_BUTTON_7</newseq>
                </port>
                <port type="START1">
                    <newseq type="standard">JOYCODE_BUTTON8_SWITCH</newseq>
                </port>
            </input>
        </controller>
        <!-- this keyboard section provides a way to specify keyboard input
         mappings that should ALSO be made for the specific port types. -->
        <controller id="keyboard">
            <input>
                <port type="P1_JOYSTICK_UP">
                    <newseq type="standard">KEYCODE_UP</newseq>
                </port>
                <port type="P1_JOYSTICK_DOWN">
                    <newseq type="standard">KEYCODE_DOWN</newseq>
                </port>
                <port type="P1_JOYSTICK_LEFT">
                    <newseq type="standard">KEYCODE_LEFT</newseq>
                </port>
                <port type="P1_JOYSTICK_RIGHT">
                    <newseq type="standard">KEYCODE_RIGHT</newseq>
                </port>
            </input>
        </controller>

        <!-- 
        ###################################################
        ACTUAL INPUT MAPPING STARTS HERE
        DO NOT actually put anything in this section.
        It is completely cleared and regenerated!
        ###################################################
        -->
        <input></input>
    </system>


    <!-- 
    ###################################################
    This is a GAME specific section
    Add additional <controller> sections here
    to define how those controllers should map for this
    particular game
    ###################################################
    -->
    <system name="ribbit">
        <!-- This would be stupid to actually use, but as an example
         For this game ("Ribbit"), reverse the UP and DOWN directions
         on the joystick -->
        <controller id="U360 Player1">
            <input>
                <port type="P1_JOYSTICK_UP">
                    <newseq type="standard">
                        JOYCODE_YAXIS_DOWN_SWITCH
                    </newseq>
                </port>
                <port type="P1_JOYSTICK_DOWN">
                    <newseq type="standard">
                        JOYCODE_YAXIS_UP_SWITCH
                    </newseq>
                </port>
            </input>
        </controller>
        <!-- 
        ###################################################
        ACTUAL INPUT MAPPING STARTS HERE
        DO NOT actually put anything in this section.
        It is completely cleared and regenerated!
        ###################################################
        -->
        <input></input>
    </system>
</mameconfig>

这导致数据集为7个表(mameconfig,controlleralias,system,controller,input,port,newseq)。所有似乎都有import xml进程插入的主键和外键。

非常感谢任何帮助。真的卡在这一个..

0 个答案:

没有答案