先看出错信息:
语法错误 (操作符丢失) 在查询表达式 'COUNT([Messages].[Id]) [COUNT_Messages_Id]' 中
数据库文件:*.mdb
C#代码为:
messagesCount = (int)DBService.Select(GuessBookTableColumns.Messages,GuessBookTableColumns.Messages.Id.Count()).Where(where).ToScalar();
NBearLite生成的cmd.CommandText 为:
"SELECT COUNT([Messages].[Id]) [COUNT_Messages_Id] FROM [Messages]"
此SQL语句在SQL中是可以正确执行的,但是在MsAccess中就必需加入 AS 才能正确执行,即:
"SELECT COUNT([Messages].[Id]) AS [COUNT_Messages_Id] FROM [Messages]"
注:此语句在SQL中也可以执行
我测试的是这样的,如有错误,请指正!