Exemplo n.º 1
0
 public override void DoRows(Parse rows)
 {
     if (String.IsNullOrEmpty(procedureName)) procedureName = Args[0];
     if (rows != null)
     {
         InitParameters(rows.Parts);
         InitCommand();
         base.DoRows(rows);
     }
     else
     {
         columnAccessors = new ColumnAccessors();
         InitCommand();
         command.ExecuteNonQuery();
     }
 }
Exemplo n.º 2
0
        // this method will initialise accessors array from the parameters that
        // really go into the insert command and columnAccessors for all columns
		private void InitParameters(Parse headerCells) {			
			Dictionary<String,DbParameterAccessor> allParams=
				dbEnvironment.GetAllColumns(tableName);
			columnAccessors = new ColumnAccessors();
            isOutputColumn = new bool[headerCells.Size];
            var paramAccessors=new List<DbParameterAccessor>();
			for (int i = 0; headerCells != null; i++, headerCells = headerCells.More) {
				String paramName= NameNormaliser.NormaliseName(headerCells.Text);
                DbParameterAccessor currentColumn;
                try
                {
                    currentColumn = allParams[paramName];
                }
                catch (KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find column " + paramName);
                }
                isOutputColumn[i] = BindingFactory.CheckIsImpliedBy(headerCells.Text);
                currentColumn.IsBoundToCheckOperation = isOutputColumn[i];
                columnAccessors.Assign(paramName, currentColumn);
                if (isOutputColumn[i])
                {
                    if (dbEnvironment.SupportsReturnOnInsert)
                    {
                        currentColumn.DbParameter.Direction = ParameterDirection.Output;
                        paramAccessors.Add(currentColumn);
                    }
                    else // don't add to paramAccessors
                    {
                        //columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType));
                        columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType,tableName));
                    }
                }
                else // not output
                {
                    currentColumn.DbParameter.Direction = ParameterDirection.Input;
                    paramAccessors.Add(currentColumn);
                }
            }
            accessors = paramAccessors.ToArray();
		}
Exemplo n.º 3
0
		private void InitParameters(Parse headerCells) {			
			Dictionary<String,DbParameterAccessor> allParams=
				dbEnvironment.GetAllColumns(tableName);

		    columnAccessors = new ColumnAccessors();
			IList<DbParameterAccessor> selectAccList=new List<DbParameterAccessor>();
			IList<DbParameterAccessor> updateAccList = new List<DbParameterAccessor>();
			for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
			{
				String paramName= NameNormaliser.NormaliseName(headerCells.Text);
                try
                {
                    DbParameterAccessor acc = allParams[paramName];
                    acc.DbParameter.Direction = ParameterDirection.Input;
                    // allow same column to be used in both sides: 
                    // remap update parameters to u_paramname and select to s_paramname
                    acc = DbParameterAccessor.Clone(acc, dbEnvironment);
                    if (headerCells.Text.EndsWith("="))
                    {
                        acc.DbParameter.ParameterName = acc.DbParameter.ParameterName+"_u";
                        updateAccList.Add(acc);
                        columnAccessors.Assign(paramName +"=", acc);
                    }
                    else
                    {
                        acc.DbParameter.ParameterName = acc.DbParameter.ParameterName+"_s";
                        selectAccList.Add(acc);
                        columnAccessors.Assign(paramName, acc);
                    }
                }
                catch (KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find column for " + paramName);
                }
			}
			selectAccessors=new DbParameterAccessor[selectAccList.Count];
			selectAccList.CopyTo(selectAccessors,0);
			updateAccessors = new DbParameterAccessor[updateAccList.Count];
			updateAccList.CopyTo(updateAccessors, 0);			
		}
Exemplo n.º 4
0
 private void InitParameters(Parse headerCells)
 {
     Dictionary<String, DbParameterAccessor> allParams =
         dbEnvironment.GetAllProcedureParameters(procedureName);
     columnAccessors = new ColumnAccessors();
     for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
     {
         String paramName = NameNormaliser.NormaliseName(headerCells.Text);
         try
         {
             DbParameterAccessor accessor = DbParameterAccessor.CloneWithSameParameter(allParams[paramName]);
             accessor.IsBoundToCheckOperation = BindingFactory.CheckIsImpliedBy(headerCells.Text);
             // sql server quirk. if output parameter is used in an input column, then 
             // the param should be remapped to IN/OUT
             if ((!accessor.IsBoundToCheckOperation) &&
                     accessor.DbParameter.Direction == ParameterDirection.Output)
                 accessor.DbParameter.Direction = ParameterDirection.InputOutput;
             columnAccessors.Assign(paramName, accessor);
             accessors.Add(accessor);
         }
         catch (KeyNotFoundException)
         {
             Wrong(headerCells);
             throw new ApplicationException("Cannot find parameter " + paramName);
         }
     }
 }