Ejemplo n.º 1
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 Accessor[headerCells.Size];
            isOutputColumn  = new bool[headerCells.Size];
            List <DbParameterAccessor> 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 (System.Collections.Generic.KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find column " + paramName);
                }
                isOutputColumn[i] = checkIsImpliedByRegex.IsMatch(headerCells.Text);
                currentColumn.IsBoundToCheckOperation = isOutputColumn[i];
                columnAccessors[i] = currentColumn;
                if (isOutputColumn[i])
                {
                    if (dbEnvironment.SupportsReturnOnInsert)
                    {
                        currentColumn.DbParameter.Direction = ParameterDirection.Output;
                        paramAccessors.Add(currentColumn);
                    }
                    else // don't add to paramAccessors
                    {
                        columnAccessors[i] = new dbfit.util.IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType);
                    }
                }
                else // not output
                {
                    currentColumn.DbParameter.Direction = ParameterDirection.Input;
                    paramAccessors.Add(currentColumn);
                }
            }
            accessors = paramAccessors.ToArray();
        }
Ejemplo 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 Accessor[headerCells.Size];
            isOutputColumn = new bool[headerCells.Size];
            List<DbParameterAccessor> 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 (System.Collections.Generic.KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find column " + paramName);
                }
                isOutputColumn[i] = checkIsImpliedByRegex.IsMatch(headerCells.Text);
                currentColumn.IsBoundToCheckOperation = isOutputColumn[i];
                columnAccessors[i] = currentColumn;
                if (isOutputColumn[i])
                {
                    if (dbEnvironment.SupportsReturnOnInsert)
                    {
                        currentColumn.DbParameter.Direction = ParameterDirection.Output;
                        paramAccessors.Add(currentColumn);
                    }
                    else // don't add to paramAccessors
                    {
                        columnAccessors[i] = new dbfit.util.IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType);
                    }
                }
                else // not output
                {
                    currentColumn.DbParameter.Direction = ParameterDirection.Input;
                    paramAccessors.Add(currentColumn);
                }
            }
            accessors = paramAccessors.ToArray();
		}