http://bbs.csdn.net/topics/380093975
有前辈也问过这个问题哈……在网上找了一圈,大概就是说没有命名空间,我找到了对应的书上的标准代码,写着“using MyPetShop;”
然后我自己调试的项目里面无法识别这个命名空间啊……什么情况呢?怎么个意思?
找不到类型或命名空间名称“MyPetshopDataContext”
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
9条回答 默认 最新
- 陌湘萘 2017-11-28 05:31关注
我终于找到原因了……
其实真的就是缺少了对就在MyPetShop.dbml了,只要在App_Code里插入对应的数据表就行了!
如果和我一样用的是不会自动生成的VS版本……就自己创建一个MyPetShop.dbml吧,代码附上:<?xml version="1.0" encoding="utf-8"?> <Database Name="MyPetShop" Class="MyPetShopDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007"> <Connection Mode="WebSettings" ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyPetShop.mdf;Integrated Security=True;User Instance=True" SettingsObjectName="System.Configuration.ConfigurationManager.ConnectionStrings" SettingsPropertyName="MyPetShopConnectionString" Provider="System.Data.SqlClient" /> <Table Name="dbo.Category" Member="Category"> <Type Name="Category"> <Column Name="CategoryId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="Name" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Descn" Type="System.String" DbType="VarChar(255)" CanBeNull="true" /> <Association Name="Category_Product" Member="Product" OtherKey="CategoryId" Type="Product" /> </Type> </Table> <Table Name="dbo.[Order]" Member="Order"> <Type Name="Order"> <Column Name="OrderId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="UserName" Type="System.String" DbType="VarChar(80) NOT NULL" CanBeNull="false" /> <Column Name="OrderDate" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" /> <Column Name="Addr1" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Addr2" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="City" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="State" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Zip" Type="System.String" DbType="VarChar(5)" CanBeNull="true" /> <Column Name="Phone" Type="System.String" DbType="VarChar(40)" CanBeNull="true" /> <Column Name="Status" Type="System.String" DbType="VarChar(10)" CanBeNull="true" /> <Association Name="Order_OrderItem" Member="OrderItem" OtherKey="OrderId" Type="OrderItem" /> </Type> </Table> <Table Name="dbo.OrderItem" Member="OrderItem"> <Type Name="OrderItem"> <Column Name="ItemId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="OrderId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="ProName" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="ListPrice" Type="System.Decimal" DbType="Decimal(10,2)" CanBeNull="true" /> <Column Name="Qty" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="TotalPrice" Type="System.Decimal" DbType="Decimal(10,2)" CanBeNull="true" /> <Association Name="Order_OrderItem" Member="Order" ThisKey="OrderId" Type="Order" IsForeignKey="true" /> </Type> </Table> <Table Name="dbo.Product" Member="Product"> <Type Name="Product"> <Column Name="ProductId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="CategoryId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="ListPrice" Type="System.Decimal" DbType="Decimal(10,2)" CanBeNull="true" /> <Column Name="UnitCost" Type="System.Decimal" DbType="Decimal(10,2)" CanBeNull="true" /> <Column Name="SuppId" Type="System.Int32" DbType="Int" CanBeNull="true" /> <Column Name="Name" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Descn" Type="System.String" DbType="VarChar(255)" CanBeNull="true" /> <Column Name="Image" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Qty" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Association Name="Category_Product" Member="Category" ThisKey="CategoryId" Type="Category" IsForeignKey="true" /> <Association Name="Supplier_Product" Member="Supplier" ThisKey="SuppId" Type="Supplier" IsForeignKey="true" /> </Type> </Table> <Table Name="dbo.Supplier" Member="Supplier"> <Type Name="Supplier"> <Column Name="SuppId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="Name" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Addr1" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Addr2" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="City" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="State" Type="System.String" DbType="VarChar(80)" CanBeNull="true" /> <Column Name="Zip" Type="System.String" DbType="VarChar(5)" CanBeNull="true" /> <Column Name="Phone" Type="System.String" DbType="VarChar(40)" CanBeNull="true" /> <Association Name="Supplier_Product" Member="Product" OtherKey="SuppId" Type="Product" /> </Type> </Table> <Function Name="dbo.CategoryInsertLinq" Method="CategoryInsertLinq"> <Parameter Name="Name" Parameter="name" Type="System.String" DbType="VarChar(80)" /> <Parameter Name="Descn" Parameter="descn" Type="System.String" DbType="VarChar(255)" /> <Return Type="System.Int32" /> </Function> </Database>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 服务端控制goose报文控制块的发布问题
- ¥15 学习指导与未来导向啊
- ¥15 求多普勒频移瞬时表达式
- ¥15 如果要做一个老年人平板有哪些需求
- ¥15 k8s生产配置推荐配置及部署方案
- ¥15 matlab提取运动物体的坐标
- ¥15 人大金仓下载,有人知道怎么解决吗
- ¥15 一个小问题,本人刚入门,哪位可以help
- ¥30 python安卓开发
- ¥15 使用R语言GD包一直不出结果