Linq to sql LINQtoSQL会产生错误的SQL吗?

Linq to sql LINQtoSQL会产生错误的SQL吗?,linq-to-sql,Linq To Sql,我正在尝试运行Linq to SQL查询,但在计算查询时,出现以下异常: System.Data.OleDb.OleDbException was unhandled Message=The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. Source=Microsoft JET Dat

我正在尝试运行Linq to SQL查询,但在计算查询时,出现以下异常:

System.Data.OleDb.OleDbException was unhandled
  Message=The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
  Source=Microsoft JET Database Engine
  ErrorCode=-2147217900
  StackTrace:
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.OleDb.OleDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.ExecuteReader()
       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
       at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
       at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
       at xxx.InventoryPopulator`2.Clear(String barcode) in F:\Projects\C#\xxx\xxx\InventoryPopulator.cs:line 38
       [..etc..]
  InnerException: 
调试器显示我的查询为:

SELECT [t0].[SupplierID] AS [Id], [t0].[SupplierSKU] AS [Sku], [t0].[LocalSKU] AS [LocalSku], [t0].[ManufacturersBarcode] AS [Barcode], [t0].[QuantityAvailable]
FROM [inventorySupplier] AS [t0]
WHERE [t0].[ManufacturersBarcode] = @p0
生成上述内容的Linq查询是:

var items = from item in this.supplierItems
            where item.Barcode == barcode
            select item;

如何修复查询?

LINQ to SQL只能与SQL Server一起使用


要对其他数据库使用LINQ,您需要一个LINQ提供程序,例如。

您是否对数据库运行生成的查询并查看它是否运行?@Raja,我在MS Access中运行了查询,它似乎运行良好;没有报告任何错误或任何内容。正如SLaks所说,Linq to SQL只能用于SQL Server。试试他建议的供应商@我已经给了你一个+1。我不太确定我怎么能用这个。。。你能举个例子吗?不能随便举个例子。您还可以使用现成的提供程序,例如。