Search found 12 matches

by freakshow
Fri 17 Apr 2009 10:53
Forum: Entity Framework support
Topic: Using TransactionScope returns no data or gives exception
Replies: 5
Views: 3383

Any updates

Any updates for this?
by freakshow
Fri 17 Apr 2009 10:52
Forum: Entity Framework support
Topic: Silently truncates string above MaxLength
Replies: 4
Views: 3583

No fix?

I cannot see (from release notes) that this is fixed yet...?
by freakshow
Tue 10 Mar 2009 11:36
Forum: Entity Framework support
Topic: Silently truncates string above MaxLength
Replies: 4
Views: 3583

Silently truncates string above MaxLength

Provider for Oracle, v5.0.22

I.e. if a varchar2 column is set to a max length of 50, a string with a length bigger than 50 will just get silently truncated by EF and inserted "normally".

I have not yet tested behaviours with other datatypes.

EF provider for MSSQL will throw an exception.

This is a critical bug, as an exception is allways expected in these kind of scenarios.
by freakshow
Tue 10 Mar 2009 08:07
Forum: Entity Framework support
Topic: Using TransactionScope returns no data or gives exception
Replies: 5
Views: 3383

Does not work in direct mode

Thanks, but this does not work in Direct mode (it works in non-direct mode).
by freakshow
Tue 03 Mar 2009 10:11
Forum: Entity Framework support
Topic: Using TransactionScope returns no data or gives exception
Replies: 5
Views: 3383

Using TransactionScope returns no data or gives exception

I am using dotConnect for Oracle 5.0.22.0. This scenario does not work in either direct or non-direct mode.

Background: Want to do integration tests

Scenario: Create a new record, save changes and verify the result (read it back).

The scenario works as expected when I am not using TransactionScope.

In direct mode I get no record back.
In non-direct mode I get an ORA-01453 error message (SET TRANSACTION must be first statement of transaction)

Code: Select all

using (TransactionScope trans = new TransactionScope())
{
	using (Entities entities = new Entities())
	{
	    var qry = from e in entities.Table1
		      select e;
	    foreach (Table1 record in qry)
	    {
		Console.WriteLine(record.Id);
	    }
	    Console.WriteLine("-----------------------");

	    Table1 newRecord = Table1.CreateTable1("SOMEID");
	    entities.AddToTable1(newRecord);
	    entities.SaveChanges();

	    var qry2 = from e in entities.Table1
		      select e;
	    
	    foreach (Table1 record in qry)
	    {
	    	Console.WriteLine(record.Id);
	    }
	    Console.WriteLine("-----------------------");
	}
}
by freakshow
Wed 21 Jan 2009 13:26
Forum: LinqConnect (LINQ to SQL support)
Topic: Exception when using Where and Count extension methods
Replies: 4
Views: 3436

It works!

It works! Excellent! Thank you!

Is the problem that the mappingsource from MS is beeing created/used if you do not specify this explicitly as Devart (just guessing)?

Will you/can you fix this in a future relase (so it is not necessary to create it manually)?
by freakshow
Wed 14 Jan 2009 15:17
Forum: LinqConnect (LINQ to SQL support)
Topic: Exception when using Where and Count extension methods
Replies: 4
Views: 3436

Exception when using Where and Count extension methods

dotConnect version: 5.00.16, Oracle db

Getting exceptions when doing basic Linq queries.

Code to reproduce the errors:

Code: Select all

using System;
using System.Data.Linq.Mapping;
using System.Linq;
using Devart.Data.Linq;


namespace DevartTest
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            1. Create a console application
            2. Make sure project references DevArt.Data.Linq, DevArt.Data.Oracle, etc...
            3. Change connectionstring below
            4. Run Oracle create script for test table:
             
            CREATE TABLE EMPLOYEE ("ID" NUMBER NOT NULL ENABLE, "NAME" NVARCHAR2(50));
            INSERT INTO EMPLOYEE (ID, NAME) VALUES (1, 'John Johnson');
            INSERT INTO EMPLOYEE (ID, NAME) VALUES (2, 'Jane Doe');
            COMMIT;

           
             */
            using (EntityContext ctx = new EntityContext())
            {
                // All the scenarios below works with Linq to Sql,


                // Scenario 1, Normal LINQ query with a where critera: Works
                Table empTable1 = ctx.GetTable();
                var qry1 = empTable1.Where(em => em.Id > 0);

                foreach (var employee in qry1)
                {
                    Console.WriteLine(employee.Id);
                }


                // Scenario 2, Normal LINQ query with a where critera: Exception
                Table empTable2 = ctx.GetTable();
                var qry2a = empTable2.Cast();
                var qry2b = qry2a.Where(em => 1==1); // works with an expression that does not use the em variable
                var qry2c = qry2a.Where(em => em.Id > 0); // does not work since expression uses the em variable

                foreach (var employee in qry2b)
                {
                    Console.WriteLine(employee.Id);
                }

                foreach (var employee in qry2c)
                {
                    Console.WriteLine(employee.Id);
                }

                // Scenario 3, Normal LINQ query with count: Exception
                Table empTable3 = ctx.GetTable();
                int count1 = empTable3.Count();
                
                Console.WriteLine(count1);

                // Scenario 4, Normal LINQ query with count (where table is casted to interface): Exception
                Table empTable4 = ctx.GetTable();
                IQueryable empTable5 = empTable4.Cast();

                int count2 = empTable5.Count();

                Console.WriteLine(count2);

            }

            Console.ReadKey();
        }

        [Provider(typeof(Devart.Data.Oracle.Linq.Provider.OracleDataProvider))]
        public class EntityContext : Devart.Data.Linq.DataContext
        {
            public EntityContext()
                : base("User Id=xx;Password=xx;Server=xx;Direct=True;Sid=xx") { }
        }

        public interface IEmployee
        {
            int Id { get; set; }
            string Name { get; set; }
        }

        [Table(Name = "EMPLOYEE")]
        public class Employee : IEmployee
        {
            [Column(Name = "ID", IsPrimaryKey = true)]
            public int Id { get; set; }

            [Column(Name = "NAME")]
            public string Name { get; set; }
        }
    }
}

See also previously similar reported errors: http://devart.com/forums/viewtopic.php?t=13619
by freakshow
Tue 09 Dec 2008 18:20
Forum: LinqConnect (LINQ to SQL support)
Topic: Exception when using IQueryable First() and FirstOrDefault()
Replies: 2
Views: 6179

Exception when using IQueryable First() and FirstOrDefault()

dotConnect version: 5.00.16

Trying to execute a codeblock that uses First or FirstOrDefault methods of the IQueryable interface throws an exception. This occours after the table is casted.

Example code:

Code: Select all

ITable table2 = ctx.GetTable(typeof(Employee));
IQueryable empTable2 = table2.Cast();
IEmployee employee2 = empTable2.FirstOrDefault();
Exception message:
Object of type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.Employee]' cannot be converted to type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.IEmployee]'.

at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Devart.Data.Linq.Provider.c.a(Type A_0, SqlNode A_1, d A_2, m A_3)
at Devart.Data.Linq.Provider.DataProvider.a(Expression A_0)
at Devart.Data.Linq.Provider.DataProvider.h(Expression A_0)
at Devart.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
at DevArtLinqToOracleExceptions.Program.Main(String[] args) in g:\tmp\DevartTest2\ConsoleApplication1\Program.cs:line 62
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
This bug was discovered after you had fixed issues reported by me in this post: http://devart.com/forums/viewtopic.php?t=13248


Console app code to reproduce the exception:

Code: Select all

using System;
using System.Data.Linq.Mapping;
using System.Linq;
using Devart.Data.Linq;

namespace DevArtLinqToOracleExceptions
{

    /* 
    1. Create a console application 
    2. Make sure project references DevArt.Data.Linq, DevArt.Data.Oracle, etc... 
    3. Change connectionstring below 
    4. Run Oracle create script for test table: 
      
    CREATE TABLE EMPLOYEE ("ID" NUMBER NOT NULL ENABLE, "NAME" NVARCHAR2(50)); 
    INSERT INTO EMPLOYEE (ID, NAME) VALUES (1, 'John Johnson'); 
    INSERT INTO EMPLOYEE (ID, NAME) VALUES (2, 'Jane Doe'); 
    COMMIT; 

    
     */

    class Program
    {
        static void Main(string[] args)
        {
            using (EntityContext ctx = new EntityContext())
            {
                // All the scenarios below works with Linq to Sql, 

                // Scenario 1 (using FirstOrDefault without interface): Works 

                var firstEmployee = (from emp in ctx.GetTable()
                                     select emp).FirstOrDefault();

                Console.WriteLine(firstEmployee.Id);

                
                // Scenario 2 (using cast with interface, but without FirstOrDefault): Works. 

                ITable table1 = ctx.GetTable(typeof(Employee));
                IQueryable empTable1 = table1.Cast();

                var qry = from e in empTable1
                          select e;

                foreach (IEmployee employee in qry)  // Throws exception here 
                {
                    Console.WriteLine(employee.Id);
                    break;
                }


                // Scenario 3 (using cast with interface and using method FirstOrDefault): Throws exception
                // Object of type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.Employee]' 
                // cannot be converted to type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.IEmployee]'.

                ITable table2 = ctx.GetTable(typeof(Employee));
                IQueryable empTable2 = table2.Cast();

                IEmployee employee2 = empTable2.FirstOrDefault();
                
            }

            Console.ReadLine();
        }
    }

    [Provider(typeof(Devart.Data.Oracle.Linq.Provider.OracleDataProvider))]
    public class EntityContext : Devart.Data.Linq.DataContext
    {
        public EntityContext()
            : base("User Id=xx;Password=xx;Server=xx;Direct=True;Sid=xx") { }
    }

    public interface IEmployee
    {
        int Id { get; set; }
        string Name { get; set; }
    }

    [Table(Name = "EMPLOYEE")]
    public class Employee : IEmployee
    {
        [Column(Name = "ID", IsPrimaryKey = true)]
        public int Id { get; set; }

        [Column(Name = "NAME")]
        public string Name { get; set; }
    }
}
by freakshow
Mon 17 Nov 2008 08:35
Forum: LinqConnect (LINQ to SQL support)
Topic: Executing an IQueryable after using Cast<T> throws Exception
Replies: 3
Views: 7310

Get different exception after relase

Hi!

I have now tested this against the release of dotConnect. Scenario 3 works, but scenario 2 still throws an exception. However, this is a different exception.

Code: Select all

Object of type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.Employee]' cannot be converted to type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.IEmployee]'.


   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Devart.Data.Linq.Provider.c.a(Type A_0, SqlNode A_1, d A_2, m A_3)
   at Devart.Data.Linq.Provider.DataProvider.a(Expression A_0)
   at Devart.Data.Linq.Provider.DataProvider.h(Expression A_0)
   at Devart.Data.Linq.DataQuery`1.i()
   at DevArtLinqToOracleExceptions.Program.Main(String[] args) in g:\tmp\DevartTest\ConsoleApplication1\Program.cs:line 53
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

This is the example from the first post - only modified to work with the release and not the "Cast" workaround:

Code: Select all

using System;
using System.Data.Linq.Mapping;
using System.Linq;
using Devart.Data.Linq;

namespace DevArtLinqToOracleExceptions
{

    /* 
    1. Create a console application 
    2. Make sure project references DevArt.Data.Linq, DevArt.Data.Oracle, etc... 
    3. Change connectionstring below 
    4. Run Oracle create script for test table: 
      
    CREATE TABLE EMPLOYEE ("ID" NUMBER NOT NULL ENABLE, "NAME" NVARCHAR2(50)); 
    INSERT INTO EMPLOYEE (ID, NAME) VALUES (1, 'John Johnson'); 
    INSERT INTO EMPLOYEE (ID, NAME) VALUES (2, 'Jane Doe'); 
    COMMIT; 

    
     */

    class Program
    {
        static void Main(string[] args)
        {
            using (EntityContext ctx = new EntityContext())
            {

                // All the scenarios below works with Linq to Sql, 
                // but only scenario 1 works with Linq to Oracle 

                // Scenario 1: Works 

                var firstEmployee = (from emp in ctx.GetTable()
                                     select emp).First();

                Console.WriteLine(firstEmployee.Id);


                // Scenario 2: Does still not work, throws:
                // Object of type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.Employee]' 
                // cannot be converted to type 'System.Func`2[System.Data.IDataRecord,DevArtLinqToOracleExceptions.IEmployee]'.

                ITable table1 = ctx.GetTable(typeof(Employee));
                IQueryable empTable1 = table1.Cast();

                var qry = from e in empTable1
                          select e;

                foreach (IEmployee employee in qry)  // Throws exception here 
                {
                    Console.WriteLine(employee.Id);
                    break;
                }


                // Scenario 3: Works now in final release

                ITable table2 = ctx.GetTable(typeof(Employee));
                IQueryable empTable2 = table2.Cast();

                foreach (Employee employee in empTable2)
                {
                    Console.WriteLine(employee.Id);
                    break;
                }
            }

            Console.ReadLine();
        }
    }

    [Provider(typeof(Devart.Data.Oracle.Linq.Provider.OracleDataProvider))]
    public class EntityContext : Devart.Data.Linq.DataContext
    {
        public EntityContext()
            : base("User Id=xx;Password=xx;Server=xx;Direct=True;Sid=xx") { }
    }

    public interface IEmployee
    {
        int Id { get; set; }
        string Name { get; set; }
    }

    [Table(Name = "EMPLOYEE")]
    public class Employee : IEmployee
    {
        [Column(Name = "ID", IsPrimaryKey = true)]
        public int Id { get; set; }

        [Column(Name = "NAME")]
        public string Name { get; set; }
    }
}
by freakshow
Wed 29 Oct 2008 13:27
Forum: LinqConnect (LINQ to SQL support)
Topic: Executing an IQueryable after using Cast<T> throws Exception
Replies: 3
Views: 7310

Executing an IQueryable after using Cast<T> throws Exception

This is related to Linq to Oracle, 5.0 beta dotConnect

After trying to cast ITable to an IQueryable, various exceptions are thrown.

I have created a complete console app that reproduces the two different exceptions I get when trying two different approaches.

Code: Select all

using System;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Devart.Data.Linq;

namespace DevArtLinqToOracleExceptions
{

    /* 
    1. Create a console application
    2. Make sure project references DevArt.Data.Linq, DevArt.Data.Oracle, etc...
    3. Change connectionstring below
    4. Run Oracle create script for test table:
     
    CREATE TABLE EMPLOYEE ("ID" NUMBER NOT NULL ENABLE, "NAME" NVARCHAR2(50));
    INSERT INTO EMPLOYEE (ID, NAME) VALUES (1, 'John Johnson');
    INSERT INTO EMPLOYEE (ID, NAME) VALUES (2, 'Jane Doe');
    COMMIT;

    
     */
   
    class Program
    {
        static void Main(string[] args)
        {

            using (EntityContext ctx = new EntityContext())
            {

                // All the scenarios below works with Linq to Sql, 
                // but only scenario 1 works with Linq to Oracle

                // Scenario 1: Works

                var firstEmployee = (from emp in ctx.GetTable()
                          select emp).First();

                Console.WriteLine(firstEmployee.Id);


                // Scenario 2: Does not work, throws NotSupportedException

                ITable table1 = ctx.GetTable(typeof(Employee));
                IQueryable empTable1 = table1.WorkaroundCast();

                var qry = from e in empTable1
                          select e;

                foreach (IEmployee employee in qry)  // Throws NotSupportedException here
                {
                    Console.WriteLine(employee.Id);
                    break;
                }

                // Scenario 3: Does not work, throw NullReferenceException

                ITable table = ctx.GetTable(typeof (Employee));
                IQueryable empTable = table.WorkaroundCast();

                foreach (Employee employee in empTable) // throws NullReferenceException here
                {
                    Console.WriteLine(employee.Id);
                    break;
                }
            }

            Console.ReadLine();
        }
    }

    [Provider(typeof(Devart.Data.Oracle.Linq.Provider.OracleDataProvider))]
    public class EntityContext : Devart.Data.Linq.DataContext
    {
        public EntityContext()
            : base("User Id=xx;Password=xx;Server=xx;Direct=True;Sid=xx") { }
    }

    public interface IEmployee
    {
        int Id { get; set; }
        string Name { get; set; }
    }

    [Table(Name = "EMPLOYEE")]
    public class Employee : IEmployee
    {
        [Column(Name = "ID", IsPrimaryKey = true)]
        public int Id { get; set; }

        [Column(Name = "NAME")]
        public string Name { get; set; }
    }

    public static class WorkaroundClass
    {
        // Workaround for NotImplemented exception as I have posted here: 
        // http://devart.com/forums/viewtopic.php?t=13237
        public static IQueryable WorkaroundCast(this IQueryable source)
        {
            MethodInfo method = ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new Type[] { typeof(TResult) });
            Expression[] expressions = new Expression[] { source.Expression };
            MethodCallExpression callExpression = Expression.Call(null, method, expressions);

            // CreateQuery(Expression) call is the one that is not implemented, so we use CreateQuery(Expression) instead
            IQueryable query = source.Provider.CreateQuery(callExpression);
            return query;
        }
    }

}
Also see the related post for why I am using a workaround Cast method:
http://devart.com/forums/viewtopic.php?t=13237

In addition to these issues beeing fixed, we really need to know if you intend to implement all features that are available to Linq to Sql in Linq to Oracle?

Freddy Hansen
by freakshow
Tue 28 Oct 2008 14:35
Forum: LinqConnect (LINQ to SQL support)
Topic: Table<T> does not implement all members of IQueryProvider
Replies: 1
Views: 4013

Table<T> does not implement all members of IQueryProvider

When using the extension method System.Linq.Cast(this IQueryable source) on your Table object it throws a NotImplementedException.

Background:
I need to return an IQueryable where T is an interface representing the table.

Code: Select all

public IQueryable Entities{
Devart.Data.Linq.ITable table = this.GetTable(ResolveType());
return table.Cast();
}

Using stacktrace and Reflector it turns out that this is a member of IQueryProvider called CreateQuery that is not implemented. The strange thing is that you implement a similar, but generic version of the same method on the interface.

Will this be fixed soon or for the release?

I am using the newest beta (downloaded today) of dotConnect.
by freakshow
Mon 28 Jul 2008 12:45
Forum: dotConnect for Oracle
Topic: Must run installer on build machine to avoid licence error?
Replies: 2
Views: 2136

Must run installer on build machine to avoid licence error?

Hi!

Do we have to run the installer on our build machine in order for the app to not get the message "License is not valid"? Is there another way around or at least a solution so we don't have to add the assemblies to the GAC?

Yes, I have read information about licensing and run the license wizard.

Ref posts like this:
http://www.devart.com/forums/viewtopic. ... ld+machine