Example #1
0
        public object Execute(ISelectIdentity Query)
        {
            DbCommand    command;
            DbDataReader reader;
            object       result = null;

            command = commandBuilder.BuildCommand(Query);

            using (DbConnection connection = connectionFactory.CreateConnection())
            {
                connection.Open();
                command.Connection = connection;

                try
                {
                    reader = command.ExecuteReader();
                }
                catch (Exception ex)
                {
                    throw new ORMException(command, ex);
                }

                using (reader)
                {
                    if (!reader.Read())
                    {
                        throw new ORMException(command, new Exception("No identity value returned"));
                    }
                    result = reader[0];
                    if (Query.ResultCallBack != null)
                    {
                        Query.ResultCallBack(result);
                    }
                }
            }

            return(result);
        }
Example #2
0
 protected override DbCommand OnBuildSelectIdentityCommand(ISelectIdentity Query)
 {
     return(new SqlCommand("SELECT @@IDENTITY"));
     //return new SqlCommand("SELECT SCOPE_IDENTITY()");
 }
Example #3
0
 public object Execute(ISelectIdentity Query)
 {
     throw new NotImplementedException();
 }
Example #4
0
 protected abstract DbCommand OnBuildSelectIdentityCommand(ISelectIdentity Query);