Error When Using DateTimeOffset (6.50.237)
Posted: Mon 24 Oct 2011 20:51
When trying to use dotConnect for Oracle 6.50.237 I discovered that I am now getting an "Unexpected type usage: PrimitiveTypeKind 'DateTimeOffset', DatabaseSpecificType: '0'." error when using a property of type DateTimeOffset in a query.
The
var query = (from p in context.RootItems
where p.Time < now
select p).ToList();
Throws thefollowing Exception:
[System.Data.EntityCommandCompilationException] = {"An error occurred while preparing the command definition. See the inner exception for details."}
InnerException:
[System.InvalidOperationException] = {"Unexpected type usage: PrimitiveTypeKind 'DateTimeOffset', DatabaseSpecificType: '0'."}
StackTrace:
at Devart.Common.Entity.ao.c(DbParameterBase A_0, e A_1)
at Devart.Data.Oracle.Entity.y.a(af A_0, DbCommandBase A_1)
at Devart.Common.Entity.a5.c()
at Devart.Data.Oracle.Entity.OracleEntityProviderServices.a(h A_0, DbCommandTree A_1)
at Devart.Data.Oracle.Entity.OracleEntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
Code: Select all
public class RootItem
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public DateTimeOffset Time { get; set; }
}
Code: Select all
public class MyDbContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove();
modelBuilder.Conventions.Remove();
}
public DbSet RootItems { get; set; }
}
Code: Select all
class Program
{
static void Main(string[] args)
{
var monitor = new OracleMonitor() { IsActive = true };
var config = OracleEntityProviderConfig.Instance;
config.Workarounds.IgnoreSchemaName = true;
config.DatabaseScript.Schema.DeleteDatabaseBehaviour = DeleteDatabaseBehaviour.ModelObjectsOnly;
System.Data.Entity.Database.SetInitializer(new DropCreateDatabaseAlways());
var now = DateTimeOffset.Now;
using (MyDbContext context = new MyDbContext())
{
var query = (from p in context.RootItems
where p.Time < now
select p).ToList();
}
}
}
var query = (from p in context.RootItems
where p.Time < now
select p).ToList();
Throws thefollowing Exception:
[System.Data.EntityCommandCompilationException] = {"An error occurred while preparing the command definition. See the inner exception for details."}
InnerException:
[System.InvalidOperationException] = {"Unexpected type usage: PrimitiveTypeKind 'DateTimeOffset', DatabaseSpecificType: '0'."}
StackTrace:
at Devart.Common.Entity.ao.c(DbParameterBase A_0, e A_1)
at Devart.Data.Oracle.Entity.y.a(af A_0, DbCommandBase A_1)
at Devart.Common.Entity.a5.c()
at Devart.Data.Oracle.Entity.OracleEntityProviderServices.a(h A_0, DbCommandTree A_1)
at Devart.Data.Oracle.Entity.OracleEntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)