MVC SportsStore:用户代码未处理systems.ArgumentException?
public class SqlProductsRepository : IProductsRepository
{
private Table<Product> productsTable;
public SqlProductsRepository(string connectionString)
{
**productsTable = (new DataContext(connectionString)).GetTable<Product>();
}
public IQueryable<Product> Products
{
get { return productsTable; }
}
}
这是来自 pro asp.net 书籍的 SportsStore 示例(这里是源代码的 github 链接)。当我运行代码时,它显示 system.ArgumentException 错误。谁能告诉我这个错误到底是什么以及如何修复它? 错误显示在粗体区域。
错误:不支持关键字:元数据”
连接字符串:
SQLRepository:
公共类 SqlProductsRepository :IProductsRepository { 私有表 products 表;
public SqlProductsRepository(string connectionString)
{
productsTable = (new DataContext(connectionString)).GetTable<Product>();
}
public IQueryable<Product> Products
{
get { return productsTable; }
}
public class SqlProductsRepository : IProductsRepository
{
private Table<Product> productsTable;
public SqlProductsRepository(string connectionString)
{
**productsTable = (new DataContext(connectionString)).GetTable<Product>();
}
public IQueryable<Product> Products
{
get { return productsTable; }
}
}
this is an SportsStore example from pro asp.net book (here is a github link to the source code). when i run the code it shows system.ArgumentException error. Can anyone tell me what exactly this error is and how can i fix it?
error shows in the bold area.
error: Keyword not supported: metadata"
connectionstring:
SQLRepository:
public class SqlProductsRepository : IProductsRepository
{
private Table productsTable;
public SqlProductsRepository(string connectionString)
{
productsTable = (new DataContext(connectionString)).GetTable<Product>();
}
public IQueryable<Product> Products
{
get { return productsTable; }
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是,connectionString 设置不正确。
更多信息请参见此处:
http://msdn.microsoft.com/en -us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx
Most likely, connectionString is not set properly.
More information is available here:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx