解决。将问题留给后人。
我定义的DTO也通过ORMLite映射到表格:
[Route("/mce/ElevatorAccessLevels/", Verbs = "POST")]
[Route("/mce/ElevatorAccessLevels/{Id}", Verbs = "PUT, DELETE")]
public class ElevatorFloorToAccessLevel
{
[AutoIncrement]
[PrimaryKey]
public int Id { get; set; }
[ForeignKey(typeof(Floor))]
public int FloorId { get; set; }
public int AccessLevelKey { get; set; }
}
使用以下语句选择表格中的所有内容时的某些原因:
var accessLevelsToFloors = db.Select<ElevatorFloorToAccessLevel>(acc => acc.AccessLevelKey == 1);
我收到以下错误:
无效的对象名称&#39; ElevatorFloorToAccessLevel&#39;
但是,当我在数据库上添加跟踪时,我看到以下内容(在sql management studio中正确返回数据):
SELECT "Id", "FloorId", "AccessLevelKey"
FROM "ElevatorFloorToAccessLevel"
WHERE ("AccessLevelKey" = 1)
这里发生了什么?谢谢!
这是一个callstack
System.Data.SqlClient.SqlException(0x80131904):无效的对象名称 &#39; ElevatorFloorToAccessLevel&#39 ;.在
System.Data.SqlClient.SqlConnection.OnError(SqlException异常, Boolean breakConnection,Action
的Func`2过滤器)1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource
1完成,Int32超时,Task&amp;任务, 布尔asyncWrite)at System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String 方法)at System.Data.SqlClient.SqlCommand.ExecuteReader(的CommandBehavior 行为,String方法)at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(的CommandBehavior 行为) System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()at ServiceStack.OrmLite.OrmLiteResultsFilterExtensions.ExprConvertToList [T](IDbCommand的 dbCmd,String sql)at ServiceStack.OrmLite.OrmLiteExecFilter.Exec [T](IDbConnection dbConn,