Мне выдано недопустимое исключение приведения с использованием LINQ to SQL. Вот мой класс по C #:
[Table(Name = "tbl_request$")]
public class request
{
[Column(IsPrimaryKey = true)]
public float requestID;
[Column]
public string moduleCode;
[Column]
public float park;
[Column]
public string requestedRoom;
[Column]
public float week;
[Column]
public float day;
[Column]
public float period;
[Column]
public float status;
[Column]
public float semester;
[Column]
public float priority;
[Column]
public float adhoc;
[Column]
public float numStudents;
[Column]
public float collectionID;
[Column]
public float roomCount;
}
Таблица базы данных соответствует
requestID float Unchecked
moduleCode nvarchar(255) Checked
park float Checked
requestedRoom nvarchar(255) Checked
week float Checked
day float Checked
period float Checked
status float Checked
semester float Checked
priority float Checked
adhoc float Checked
numStudents float Checked
collectionID float Checked
roomCount float Checked
Все выглядит хорошо для меня. Любые другие предложения?
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 12: var bookingtable = Database.DatabaseContext.GetTable<Database.request>();
Line 13: var dict = new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<Database.request>>();
Line 14: foreach (var request in bookingtable)
Line 15: {
Line 16: if (dict[(int)request.collectionID] == null)
Трассировка стека находится глубоко внутри внутренних компонентов LINQ.