Cannot execute mapped stored procedure

Cannot execute mapped stored procedure

Postby ShmInf » Tue 16 Aug 2011 14:32

dotConnect for PostgreSql version: 5.30.165.0

1. I have this stored procedure

Code: Select all
CREATE OR REPLACE FUNCTION AssignMentionsToTask(taskId bigint, mentionIds TEXT) RETURNS VOID
AS
'
  -- UPDATE EVERYTHING i NEED... PLEASE...
'
LANGUAGE SQL
    VOLATILE
    RETURNS NULL ON NULL INPUT;


2. This code has been generated by the mapping tool.
Code: Select all
public void AssignMentionsToTask (global::System.Nullable taskid, string mentionids)
        {
            if (this.Connection.State != System.Data.ConnectionState.Open)
              this.Connection.Open();
            System.Data.EntityClient.EntityCommand command = new System.Data.EntityClient.EntityCommand();
            if(this.CommandTimeout.HasValue)
              command.CommandTimeout = this.CommandTimeout.Value;
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.CommandText = @"DataEntities.AssignMentionsToTask";
            command.Connection = (System.Data.EntityClient.EntityConnection)this.Connection;
            EntityParameter taskidParameter = new EntityParameter("taskid", System.Data.DbType.Int64);
            if (taskid.HasValue)
                taskidParameter.Value = taskid;
            command.Parameters.Add(taskidParameter);
            EntityParameter mentionidsParameter = new EntityParameter("mentionids", System.Data.DbType.String);
            if (mentionids != null)
                mentionidsParameter.Value = mentionids;
            command.Parameters.Add(mentionidsParameter);
            command.ExecuteNonQuery();
        }



3. I run it and the line "command.ExecuteNonQuery()" generates this error
Code: Select all
EntityCommandExecutionException
   InnerException: The method or operation is not implemented.
   StackStace:       at Devart.Common.Entity.au.d()
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at Devart.Data.PostgreSql.Entity.j.a(CommandBehavior A_0)
   at Devart.Common.Entity.b5.b(CommandBehavior A_0)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)


What am I doing wrong?
ShmInf
 
Posts: 3
Joined: Tue 16 Aug 2011 13:49

Postby Shalex » Wed 17 Aug 2011 13:16

ShmInf wrote:This code has been generated by the mapping tool.

1. Could you please specify which mapping tool and its template you have used?
2. Does the problem persist with the latest (5.30.202) version of dotConnect for PostgreSQL?
3. Tell us the exact version of your Visual Studio (the Help > About menu).
4. If possible, send us a small test project with your model to reproduce the issue in our environment.

As an alternative, try using the Devart Entity Model item: right click on your project in Solution Explorer > Add > New Item > Devart Entity Model (the Data section).
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44

Postby ShmInf » Thu 18 Aug 2011 14:05

1. Entity developer
2. ?
3. doesn't matter
4. It is simple to reproduce. see below...

This occurs when we use Batch updates!


Add this code to you DataEntities class

Code: Select all
        static DataEntities()
        {
            var config = PgSqlEntityProviderConfig.Instance;
            config.DmlOptions.BatchUpdates.Enabled = true;
            config.DmlOptions.BatchUpdates.BatchSize = 1000;
        }


Look at this code

Code: Select all
protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior, bool nonQuery)
{
    DbDataReader reader2;
    Utils.CheckConnectionOpen(base.Connection);
    if (this.HasOpenReader)
    {
        throw new InvalidOperationException(n.a("ReaderNotClosed"));
    }
    IDisposable h = this.h;
    using (this.LocalFailoverManager.StartUse(true))
    {
        bool flag;
    Label_0038:
        flag = false;
        try
        {
            DbDataReader reader;
            if (h == null)
            {
                h = this.InternalPrepare(true, 0, 0);
                flag = this.IsReadOnlyOperation(h);
                try
                {
                    reader = this.InternalExecute(behavior, h, 0, 0, nonQuery);
                    this.AddDataReader(reader);
                    return reader;
                }
                catch
                {
                    try
                    {
                        h.Dispose();
                    }
                    catch
                    {
                    }
                    h = null;
                    throw;
                }
                finally
                {
                    if (h != null)
                    {
                        h.Dispose();
                    }
                }
            }
            reader = this.InternalExecute(behavior, h, 0, 0, nonQuery);
            flag = this.IsReadOnlyOperation(h);
            Utils.SetWeakTarget(ref this.weakDataReader, reader);
            this.AddDataReader(reader);
            reader2 = reader;
        }
        catch (Exception exception)
        {
            if (this.LocalFailoverManager.DoLocalFailoverEvent(this, ConnectionLostCause.Execute, flag ? RetryMode.Reexecute : RetryMode.Raise, exception) == RetryMode.Raise)
            {
                throw;
            }
            goto Label_0038;
        }
    }
    return reader2;
}


this line generates the error.
Code: Select all
using (this.LocalFailoverManager.StartUse(true))


LocalFailoverManager implemented in Devart.Data.PostgreSql.Entity.dll

Code: Select all
internal class au : DbCommandBase, ICloneable
{
...
protected override ILocalFailoverManager d()
{
    throw new NotImplementedException();
}
...
}



So... It looks like we cannot use batch updates and stored procedure mapping together

P.S. Let me know it you still need the simple application to reproduce the error.
ShmInf
 
Posts: 3
Joined: Tue 16 Aug 2011 13:49

Postby StanislavK » Tue 23 Aug 2011 11:41

As far as I can understand, you've mapped a stored procedure to the update operation of an entity class. Am I correct? We couldn't reproduce the problem with batch updates in this situation.

I will send you a test project, please check that the letter is not blocked by your mail filter.

Please specify what should be changed in the sample to reproduce the issue, or send us your test project, so that we are able to analyze the issue in details.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby ShmInf » Tue 23 Aug 2011 13:00

That's it. Just run the stored procedure.

Code: Select all
        static void Main(string[] args)
        {
                        ...
            ent.Updatedept(0, "test", "test");
        }
ShmInf
 
Posts: 3
Joined: Tue 16 Aug 2011 13:49

Postby StanislavK » Fri 26 Aug 2011 15:51

Thank you for your assistance, we have reproduced the problem. We will analyze it and inform you about the results.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby Shalex » Fri 09 Sep 2011 13:12

The bug with executing Funtion Imports with enabled BatchUpdates is fixed. We will post here when the corresponding build of dotConnect for PostgreSQL is available for download.
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44

Postby Shalex » Fri 30 Sep 2011 12:49

New build of dotConnect for PostgreSQL 5.50.228 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=22166 .
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL