Exemple #1
0
 //This function returns sql string: DELETE ... WHERE
 protected static string BuildSqlDelete(string tableName, PrimaryKey key)
 {
     return(BuildSqlDelete(tableName, new PrimaryKey[1] {
         key
     }));
 }
Exemple #2
0
 //This function returns sql string: SELECT ... FROM ... WHERE ...
 protected static string BuildSqlSelect(Object item, string tableName, PrimaryKey key, bool IsSelectAll)
 {
     return(BuildSqlSelect(item, tableName, new PrimaryKey[1] {
         key
     }, IsSelectAll));
 }
Exemple #3
0
 //This function returns sql string: UPDATE ... WHERE ...
 protected static string BuildSqlUpdate(Object businessObject, string tableName, PrimaryKey key)
 {
     return(BuildSqlUpdate(businessObject, tableName, new PrimaryKey[1] {
         key
     }));
 }
Exemple #4
0
        //Generate Primary Key for WHERE CLAUSE ...
        protected static PrimaryKey[] GeneratePrimaryKeys(string[] paramNames, Object[] paramValues, DbFieldType[] paramTypes, DbSearchType[] paramSearch)
        {
            if (paramNames == null)
            {
                return(null);
            }
            if (paramValues == null)
            {
                return(null);
            }
            if (paramTypes == null)
            {
                return(null);
            }

            if (paramNames.Length != paramValues.Length)
            {
                return(null);
            }
            if (paramNames.Length != paramTypes.Length)
            {
                return(null);
            }
            if (paramSearch != null)
            {
                if (paramNames.Length != paramSearch.Length)
                {
                    return(null);
                }
            }

            PrimaryKey[] pks = new PrimaryKey[paramNames.Length];
            Int16        idx = 0;

            foreach (Object param in paramNames)
            {
                //Names
                if (string.IsNullOrEmpty(paramNames[idx]))
                {
                    return(null);
                }

                //Values
                if (string.IsNullOrEmpty(Convert.ToString(paramValues[idx])))
                {
                    paramValues[idx] = "null";
                }
                if (paramValues[idx].ToString().Contains("1/1/0001"))
                {
                    paramValues[idx] = "null";
                }
                if (paramValues[idx].ToString().Contains("1/1/1900"))
                {
                    paramValues[idx] = "null";
                }

                if (paramSearch == null)
                {
                    pks[idx] = new PrimaryKey(paramNames[idx], Convert.ToString(paramValues[idx]), paramTypes[idx]);
                }
                else
                {
                    pks[idx] = new PrimaryKey(paramNames[idx], Convert.ToString(paramValues[idx]), paramTypes[idx], paramSearch[idx]);
                }

                idx++;
            }

            return(pks);
        }