problem calling the Stored procedure using ExecuteStoreQuery

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
sivaprasad.bevara
Posts: 4
Joined: Thu 25 Aug 2011 13:30

problem calling the Stored procedure using ExecuteStoreQuery

Post by sivaprasad.bevara » Wed 28 Mar 2012 10:09

Hi,

I am using EF 4.1 code first approach (Silver light 5).

I am facing the following issue while calling the stored procedure from the domain service.


ORA-00900: invalid SQL statement


Following the stored procedure:

Code: Select all

create or replace package types
as
    type cursorType is ref cursor;
end;
/ 

create or replace procedure GetLookupData( p_cursor in out types.cursorType )
as
begin
open p_cursor for SELECT 1 as Id, 'siva' as Name from tbl;
end;
/
Following is the code in the Domain service.

Code: Select all

public List GetMyclass()
        {
            	List result = null;         
                	string SQLQuery = "exec Schema.GetLookupData";
                	result = _context.ExecuteStoreQuery(SQLQuery).AsQueryable().ToList();               
            
            	return result;
        }
Please help.

Regards,
SivaPrasad.B[/code]

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 02 Apr 2012 13:32

Please try using this code:

Code: Select all

    class Program {
        static void Main(string[] args) {
            Devart.Data.Oracle.OracleMonitor monitor = new Devart.Data.Oracle.OracleMonitor() { IsActive = true };
            Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig config =
                Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
            config.Workarounds.IgnoreSchemaName = true;

            MyDbContext context = new MyDbContext();
            string SQLQuery = @"begin GetLookupData(:CUR); end;";
            Devart.Data.Oracle.OracleParameter param1 = new Devart.Data.Oracle.OracleParameter();
            param1.ParameterName = "CUR";
            param1.OracleDbType = Devart.Data.Oracle.OracleDbType.Cursor;
            param1.Direction = System.Data.ParameterDirection.Output;

            var result = (context as IObjectContextAdapter).ObjectContext.ExecuteStoreQuery(SQLQuery, param1).ToList();
        }
    }

    public class MyDbContext : DbContext {
        public MyDbContext()
            : base() {
        }
        public MyDbContext(DbConnection connection)
            : base(connection, true) {
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder) {
            modelBuilder.Conventions
              .Remove();
            modelBuilder.Conventions
              .Remove();
        }
        public DbSet MyClasses { get; set; }
    }

    public class MyClass {
        [Key]
        public long Id { get; set; }
        public string Name { get; set; }
    } 

Post Reply