예제 #1
0
 public List <object[]> Select(string join, string what, string whereClause, object[] vars, string orderBy, uint limit)
 {
     return(SqlController.Select(tableName,
                                 join,
                                 what ?? (join == null ? "*" : tableName + ".*"),
                                 whereClause,
                                 vars,
                                 orderBy,
                                 limit));
 }
예제 #2
0
        private bool RefreshColumnsByUniqueKey(uint value)
        {
            string          whereClause = table.additionalKeyHeaders[value - (table.primaryKeyHeaders?.Length ?? 0)].name + "=?a";
            List <object[]> newValues   = SqlController.Select(table.tableName, null, "*", whereClause, new[] { values[value] }, null, 1);

            if (newValues != null && newValues.Count > 0)
            {
                return(Set(newValues[0]));
            }

            Debug.Fail();
            return(false);
        }
예제 #3
0
 private bool AddOrUpdateRow(bool lazySave)
 {
     return(SqlController.AddOrUpdate(table, ref values, lazySave));
 }
예제 #4
0
 private bool InsertAndGetAutoIncrementingKey(bool lazySave)
 {
     return(SqlController.AddOrUpdatedAndGetAutoIncrementingKey(table, ref values, lazySave));
 }
예제 #5
0
        public SqlTable(string tableName)
        {
            if (tableName != null && tableName.Trim().Length > 0)
            {
                this.tableName = tableName;

                SqlColumnHeaders[] columns = SqlController.GetColumns(tableName);
                if (columns != null && columns.Length > 0)
                {
                    uint primaryKeyCount = 0;
                    foreach (SqlColumnHeaders column in columns)
                    {
                        if (column.isPrimaryKey)
                        {
                            primaryKeyCount++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (primaryKeyCount > 0)
                    {
                        primaryKeyHeaders = new SqlColumnHeaders[primaryKeyCount];
                    }
                    else
                    {
                        primaryKeyHeaders = null;
                    }

                    long additionalKeyCount = columns.Length - primaryKeyCount;
                    if (additionalKeyCount > 0)
                    {
                        additionalKeyHeaders = new SqlColumnHeaders[additionalKeyCount];
                    }
                    else
                    {
                        additionalKeyHeaders = null;
                    }

                    for (int i = 0; i < columns.Length; i++)
                    {
                        if (i < primaryKeyCount)
                        {
                            Debug.Assert(columns[i].isPrimaryKey);

                            primaryKeyHeaders[i] = columns[i];
                        }
                        else
                        {
                            Debug.Assert(!columns[i].isPrimaryKey);

                            additionalKeyHeaders[i - primaryKeyCount] = columns[i];
                        }
                    }
                }
                else
                {
                    throw new ArgumentNullException();
                }
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
예제 #6
0
 public bool Update(string join, string set, string where, object[] vars)
 {
     return(SqlController.Update(this, join, set, where, vars));
 }