我创建了test.dbml的文件,往里面拖了两个表DataCenter.SysData.TestDataContext textlinq = new DataCenter.SysData.TestDataContext();
然后悲剧就出现了,
testlinq下面只有两个属性,没有任何可用的方法,
我是.net3.5 vs 2008为什么没有任何数据库操作的方法
是不是需要设置些什么才能像网上的例子一样使用LINQ?

解决方案 »

  1.   

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="DataCenter.Properties.Settings.DWIMConnectionString"
                connectionString="Data Source=SHENCB;Initial Catalog=DWIM;Persist Security Info=True;User ID=sa;Password=shencb"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    </configuration>
      

  2.   

    配置文件就只有这么一点东西,linq所在的项目是作为数据层的一个项目,appconfig里就只有一条连接语句
      

  3.   

    我是说你Test.TBML下面的.layout内的配置文件!!
      

  4.   

    OK<?xml version="1.0" encoding="utf-8"?>
    <ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11, 8.5" name="CGReturn">
      <DataContextMoniker Name="/CGReturnDataContext" />
      <nestedChildShapes>
        <classShape Id="a226e2f7-8081-40c7-8e89-3df142b0fa67" absoluteBounds="0.75, 1.25, 2, 2.9659244791666666">
          <DataClassMoniker Name="/CGReturnDataContext/CGReturnOrder" />
          <nestedChildShapes>
            <elementListCompartment Id="1898e1e9-461f-4fc8-819b-88ea6260aaf8" absoluteBounds="0.76500000000000012, 1.71, 1.9700000000000002, 2.4059244791666665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
          </nestedChildShapes>
        </classShape>
        <classShape Id="829e15b1-9da5-4953-b4c5-96f05fa07f38" absoluteBounds="3.5, 1, 2, 3.4717838541666666">
          <DataClassMoniker Name="/CGReturnDataContext/CGReturnDetail" />
          <nestedChildShapes>
            <elementListCompartment Id="e9abee6f-0a87-4fdc-adb5-6f5c22c4e5e5" absoluteBounds="3.5149999999999997, 1.46, 1.9700000000000002, 2.9117838541666665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
          </nestedChildShapes>
        </classShape>
        <associationConnector edgePoints="[(2.75 : 2.73296223958333); (3.5 : 2.73296223958333)]" fixedFrom="Algorithm" fixedTo="Algorithm">
          <AssociationMoniker Name="/CGReturnDataContext/CGReturnOrder/CGReturnOrder_CGReturnDetail" />
          <nodes>
            <classShapeMoniker Id="a226e2f7-8081-40c7-8e89-3df142b0fa67" />
            <classShapeMoniker Id="829e15b1-9da5-4953-b4c5-96f05fa07f38" />
          </nodes>
        </associationConnector>
      </nestedChildShapes>
    </ordesignerObjectsDiagram>
      

  5.   

    发错了,是这个<?xml version="1.0" encoding="utf-8"?>
    <ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11, 8.5" name="Test">
      <DataContextMoniker Name="/TestDataContext" />
      <nestedChildShapes>
        <classShape Id="83aa9877-9ca4-4fff-a454-20e1bca83f94" absoluteBounds="1, 1.125, 2, 1.2797265625">
          <DataClassMoniker Name="/TestDataContext/Category1" />
          <nestedChildShapes>
            <elementListCompartment Id="6a1fd0df-3833-4141-890d-b2c52c2d192e" absoluteBounds="1.0150000000000001, 1.585, 1.9700000000000002, 0.7197265625" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
          </nestedChildShapes>
        </classShape>
        <classShape Id="87b4f70b-e52d-486a-8862-e44fe71f1ea8" absoluteBounds="1, 3.25, 2, 1.4483463541666668">
          <DataClassMoniker Name="/TestDataContext/Category2" />
          <nestedChildShapes>
            <elementListCompartment Id="8699b901-2778-4085-bc3c-132d303fb749" absoluteBounds="1.0150000000000001, 3.71, 1.9700000000000002, 0.88834635416666674" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
          </nestedChildShapes>
        </classShape>
        <associationConnector edgePoints="[(2 : 2.4047265625); (2 : 3.25)]" fixedFrom="Algorithm" fixedTo="Algorithm">
          <AssociationMoniker Name="/TestDataContext/Category1/Category1_Category2" />
          <nodes>
            <classShapeMoniker Id="83aa9877-9ca4-4fff-a454-20e1bca83f94" />
            <classShapeMoniker Id="87b4f70b-e52d-486a-8862-e44fe71f1ea8" />
          </nodes>
        </associationConnector>
      </nestedChildShapes>
    </ordesignerObjectsDiagram>
      

  6.   

    你实例化的时候用这个TestDataContext data=new TestDataContext();//你上面写的我不知道你从哪里看到的!!
      

  7.   

    <ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11, 8.5" name="Test">
      <DataContextMoniker Name="/TestDataContext" />//一定要对应这里面的name
      

  8.   

    DataCenter.SysData.TestDataContext textlinq = new DataCenter.SysData.TestDataContext(); 
    DataCenter.SysData是类库啊
      

  9.   

    dbml Database Mark Language。 数据库描述语言,是一种xml格式的文档,用来描述数据库
    DataContext dbContext = new DataContext(ConfigurationManager.ConnectionStrings[""].ConnectionString); 
      

  10.   

    TestDataContext  我这里无法识别,
    因为我的Test.dbml文件是放在另一个项目里的。
      

  11.   

    回楼主的,引用过来的。
    除了linq不能正常使用外,该项目中其他的文件都可以正常使用