Итак , есть табличка и код:
CREATE TABLE GSDBASES (
ID INTEGER NOT NULL,
PUBLISHDATE TIMESTAMP NOT NULL,
PUBLISHUSERNAME VARCHAR(255) NOT NULL,
FILENAME VARCHAR(260) NOT NULL,
DATA BLOB SUB_TYPE 0 SEGMENT SIZE 80 NOT NULL,
REGIONNAME VARCHAR(1024) NOT NULL,
REGIONCODE INTEGER NOT NULL,
VER INTEGER NOT NULL,
CREATIONDATE TIMESTAMP NOT NULL,
COMMENT VARCHAR(1042) NOT NULL
);
public abstract class UpdateBase
{
[PrimaryKey]
public int Id { get; set; }
[DisplayName("Дата публикации")]
public DateTime PublishDate { get; set; }
}
[TableName("GsdBases")]
public class GsdBase : UpdateBase
{
}
Вот такое использование приводит к ошибке:
IQueryable<GsdBase> GetGsdBaseTable()
{
return _db.GetTable<GsdBase>().Where(rec => rec.Version == GsdVersion.Ver5);
}
IQueryable<UpdateBase> GetUpdateTable()
{
return _db.GetTable<GsdBase>().Where(rec => rec.Version == GsdVersion.Ver5);
}
public ContentResult Info(string fileType, int id)
{
var update = GetUpdateTable().Where(rec => rec.Id == id).First();
}
Текст ошибки:
'rec.Id' cannot be converted to SQL.
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: BLToolkit.Data.Linq.LinqException: 'rec.Id' cannot be converted to SQL.
Source Error:
Line 1522: }
Line 1523:
Line 1524: throw new LinqException("'{0}' cannot be converted to SQL.", expression);
Line 1525: }
Line 1526: finally
Source File: D:\Jack128\LicServer.New\Lib\BLToolkit\Source\Data\Linq\ExpressionParser.QueryBuilder.cs Line: 1524
если без ковариантности — работает как надо:
public ContentResult Info(string fileType, int id)
{
var update = GetGsdBaseTable().Where(rec => rec.Id == id).First();
}
Что делать? Как жить дальше???