private static void AddParamUpdate(IDbCommand cm, Type type, string fieldName, object currentObj, object value)
        {
            string paramName = PARAM_PREFIX + fieldName;

            // Get length of string(char, varchar, nvarchar) columns
            IList stringColumns = GetLengthOfStringColumns(currentObj.GetType().Name);

            // if type is char
            if (type == typeof(System.Char))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.AnsiStringFixedLength, LengthOfStringColumns(stringColumns, fieldName), value);
            }
            // if type is string
            else if (type == typeof(System.String))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.String, LengthOfStringColumns(stringColumns, fieldName), value);
            }
            // if type is byte
            else if (type == typeof(System.Byte))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Byte, value);
            }
            // if type is smallint
            else if (type == typeof(System.Int16))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Int16, value);
            }
            // if type is int
            else if (type == typeof(System.Int32))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Int32, value);
            }
            // if type is long
            else if (type == typeof(System.Int64))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Int64, value);
            }
            // if type is decimal
            else if (type == typeof(System.Decimal))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Decimal, value);
            }
            // if type is double
            else if (type == typeof(System.Double))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Double, value);
            }
            // if type is datetime
            else if (type == typeof(System.DateTime))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.DateTime, value);
            }
            // if type is datetime
            else if (type == typeof(System.Boolean) || type == typeof(Nullable <System.Boolean>))
            {
                DGCDataParameter.AddParameter(cm, paramName, DbType.Boolean, value);
            }
        }
 // make parameters
 public static void PrepareParametersList(IDbCommand cm, DGCParameter[] parameters)
 {
     // set param for Input Parameters
     if (parameters != null)
     {
         foreach (DGCParameter param in parameters)
         {
             DGCDataParameter.AddParameter(cm, param.ParameterName, param.DbType, param.Value, param.Direction);
         }
     }
 }
 public static void PrepareParametersListWithSourceColumn(IDbCommand cm, DGCParameter[] parameters)
 {
     // set param for Input Parameters
     if (parameters != null)
     {
         foreach (DGCParameter param in parameters)
         {
             if (!param.Size.Equals(default(int)))
             {
                 DGCDataParameter.AddParameter(cm, param.ParameterName, param.DbType, param.Size, param.SourceColumn, param.SourceVersion);
             }
             else
             {
                 DGCDataParameter.AddParameter(cm, param.ParameterName, param.DbType, param.SourceColumn, param.SourceVersion);
             }
         }
     }
 }
        // make parameters
        public static void PrepareParametersDelete(IDbCommand cm, object obj, string[] primaryKeyNames)
        {
            FieldInfo[] myFieldInfo;

            //get Type of object
            Type myType = obj.GetType();

            // Get the type and fields of FieldInfoClass.
            myFieldInfo = myType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance
                                           | BindingFlags.Public);

            // if exist any parameters
            if (primaryKeyNames != null)
            {
                foreach (string primaryKeyName in primaryKeyNames)
                {
                    FieldInfo field = myType.GetField(primaryKeyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);

                    //get type of field
                    Type type = field.FieldType;
                    // convert value to DB value
                    object value = DBConvert.ParseToDBValue(field.GetValue(obj));

                    //get paramname
                    string paramName = PARAM_PREFIX + field.Name;

                    // if type is char
                    if (type == typeof(System.Char))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.AnsiStringFixedLength, value);
                    }
                    // if type is string
                    else if (type == typeof(System.String))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.String, value);
                    }
                    // if type is smallint
                    else if (type == typeof(System.Int16))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Int16, value);
                    }
                    // if type is byte
                    else if (type == typeof(System.Byte))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Byte, value);
                    }
                    // if type is int
                    else if (type == typeof(System.Int32))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Int32, value);
                    }
                    // if type is long
                    else if (type == typeof(System.Int64))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Int64, value);
                    }
                    // if type is decimal
                    else if (type == typeof(System.Decimal))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Decimal, value);
                    }
                    // if type is double
                    else if (type == typeof(System.Double))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Double, value);
                    }
                    // if type is datetime
                    else if (type == typeof(System.DateTime))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.DateTime, value);
                    }
                }
            }
        }
        // make parameters
        public static void PrepareParametersLoad(IDbCommand cm, object obj, string[] primaryKeyNames)
        {
            FieldInfo[] myFieldInfo;

            //get Type of object
            Type myType = obj.GetType();

            // Get the type and fields of FieldInfoClass.
            myFieldInfo = myType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance
                                           | BindingFlags.Public);

            if (primaryKeyNames != null)
            {
                foreach (string primaryKey in primaryKeyNames)
                {
                    for (int i = 0; i < myFieldInfo.Length; i++)
                    {
                        //get paramname
                        string paramName = PARAM_PREFIX + myFieldInfo[i].Name;

                        // if( primaryKey is equal fieldname)
                        if (primaryKey.Equals(myFieldInfo[i].Name, StringComparison.OrdinalIgnoreCase))
                        {
                            //get type of field
                            Type type = myFieldInfo[i].FieldType;

                            // convert value to DB value
                            object value = DBConvert.ParseToDBValue(myFieldInfo[i].GetValue(obj));

                            // if type is char
                            if (type == typeof(System.Char))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.AnsiStringFixedLength, value);
                            }
                            // if type is string
                            else if (type == typeof(System.String))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.String, value);
                            }
                            // if type is byte
                            else if (type == typeof(System.Byte))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.Byte, value);
                            }
                            // if type is smallint
                            else if (type == typeof(System.Int16))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.Int16, value);
                            }
                            // if type is int
                            else if (type == typeof(System.Int32))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.Int32, value);
                            }
                            // if type is long
                            else if (type == typeof(System.Int64))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.Int64, value);
                            }
                            // if type is decimal
                            else if (type == typeof(System.Decimal))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.Decimal, value);
                            }
                            // if type is double
                            else if (type == typeof(System.Double))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.Double, value);
                            }
                            // if type is datetime
                            else if (type == typeof(System.DateTime))
                            {
                                DGCDataParameter.AddParameter(cm, paramName, DbType.DateTime, value);
                            }
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// For Max val filed By Identity
        /// </summary>
        /// <param name="cm"></param>
        /// <param name="obj"></param>
        public static void PrepareParametersInsertWithMaxField(DbCommand cm, object obj, string fieldMax)
        {
            // get length of string columns from database
            IList stringColumns = GetLengthOfStringColumns(obj.GetType().Name);

            FieldInfo[] myFieldInfo;

            //get Type of object
            Type myType = obj.GetType();

            // Get the type and fields of FieldInfoClass.
            myFieldInfo = myType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance
                                           | BindingFlags.Public);

            for (int i = 0; i < myFieldInfo.Length; i++)
            {
                //get type of field
                Type type = myFieldInfo[i].FieldType;

                // if this field not have minvalue of long or int, add parameter
                if (!((myFieldInfo[i].FieldType == typeof(int) && (int)myFieldInfo[i].GetValue(obj) == int.MinValue) ||
                      (myFieldInfo[i].FieldType == typeof(byte) && (byte)myFieldInfo[i].GetValue(obj) == byte.MinValue) ||
                      (myFieldInfo[i].FieldType == typeof(long) && (long)myFieldInfo[i].GetValue(obj) == long.MinValue) ||
                      (myFieldInfo[i].Name.EndsWith("Desc"))))
                {
                    // convert value to DB value
                    object value = DBConvert.ParseToDBValue(myFieldInfo[i].GetValue(obj));

                    //get paramname
                    string paramName = PARAM_PREFIX + myFieldInfo[i].Name;

                    // if type is char
                    if (type == typeof(System.Char))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.AnsiStringFixedLength, LengthOfStringColumns(stringColumns, myFieldInfo[i].Name), value);
                    }
                    // if type is string
                    else if (type == typeof(System.String))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.String, LengthOfStringColumns(stringColumns, myFieldInfo[i].Name), value);
                    }
                    // if type is byte
                    else if (type == typeof(System.Byte))
                    {
                        DGCDataParameter.AddParameter(cm, paramName, DbType.Byte, value);
                    }
                    // if type is smallint
                    else if (type == typeof(System.Int16))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.Int16, value);
                    }
                    // if type is int
                    else if (type == typeof(System.Int32))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.Int32, value);
                    }
                    // if type is long
                    else if (type == typeof(System.Int64))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.Int64, value);
                    }
                    // if type is decimal
                    else if (type == typeof(System.Decimal))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.Decimal, value);
                    }
                    // if type is double
                    else if (type == typeof(System.Double))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.Double, value);
                    }
                    // if type is datetime
                    else if (type == typeof(System.DateTime))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.DateTime, value);
                    }
                    // if type is datetime
                    else if (type == typeof(System.Boolean))
                    {
                        DBHelper.AddParameter(cm, paramName, DbType.Boolean, value);
                    }
                }
            }
        }