示例#1
0
        public static EasyBaseColumn COLLECT(EasyBaseColumn column, object result, int index, object value, bool condition)
        {
            if (result == null && value != null)
            {
                if (value.GetType() == typeof(int))
                {
                    result = new EasyIntColumn();
                }
                else if (value.GetType() == typeof(string))
                {
                    result = new EasyStringColumn();
                }
                else if (value.GetType() == typeof(bool))
                {
                    result = new EasyBoolColumn();
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            if (result == null)
            {
                return(null);
            }

            EasyBaseColumn b = (EasyBaseColumn)result;

            //if (condition) deðiþtirme!!!
            b.Insert(value);

            return(b);
        }
示例#2
0
        public void CreateTableFromSchema()
        {
            EasyTable      tables       = FindTable(1);
            EasyTable      columnsTable = FindTable(2);
            EasyBaseColumn column       = tables.FindColumn("table_name");
            int            index        = column.GetRowCount() - 1;

            string tablename = (string)tables.FindColumn("table_name").GetValue(index);

            EasyIntColumn inx = (EasyIntColumn)
                                columnsTable.FindColumn("table_name").Custom("=", tablename, EasyBaseColumn.IA);

            List <CreateField> columns = new List <CreateField>();

            for (int i = 0; i < inx.GetRowCount(); i++)
            {
                int         j     = (int)inx.GetValue(i);
                CreateField field = new CreateField();
                field.Name       = (string)columnsTable.FindColumn("column_name").GetValue(j);
                field.IsIdentity = (bool)columnsTable.FindColumn("is_identity").GetValue(j);
                string data = (string)columnsTable.FindColumn("data_type").GetValue(j);
                field.FieldType = Type.GetType("System." + data);

                columns.Add(field);
            }

            CreateTableStructure(tablename, columns, 0, null);
        }
示例#3
0
 public void Delete(EasyTable table, EasyBaseColumn condition)
 {
     if (condition is EasyBoolColumn)
     {
         EasyBoolColumn b = (EasyBoolColumn)condition;
         int            l = b.GetRowCount();
         for (int i = 0; i < l; i++)
         {
             if (b.Values[i])
             {
                 table.Delete(i, Transaction);
             }
         }
     }
     else if (condition is EasyIntColumn)
     {
         EasyIntColumn iCol = (EasyIntColumn)condition;
         int           l    = iCol.GetRowCount();
         for (int i = 0; i < l; i++)
         {
             table.Delete(iCol.Values[i], Transaction);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
示例#4
0
 public void Update(EasyTable table, EasyBaseColumn condition, KeyValuePair <string, object>[] values)
 {
     if (condition is EasyBoolColumn)
     {
         EasyBoolColumn b = (EasyBoolColumn)condition;
         int            l = b.GetRowCount();
         for (int i = 0; i < l; i++)
         {
             if (b.Values[i])
             {
                 table.Update(i, values, Transaction);
             }
         }
     }
     else if (condition is EasyIntColumn)
     {
         EasyIntColumn iCol = (EasyIntColumn)condition;
         int           l    = iCol.GetRowCount();
         for (int i = 0; i < l; i++)
         {
             table.Update(iCol.Values[i], values, Transaction);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
示例#5
0
        /// <summary>
        /// Index Array
        /// </summary>
        public static EasyIntColumn IA(EasyBaseColumn column, object result, int index, object value, bool condition)
        {
            if (result == null)
            {
                result = new EasyIntColumn();
            }
            EasyIntColumn b = (EasyIntColumn)result;

            if (condition)
            {
                b.Insert(index);
            }

            return(b);
        }
示例#6
0
        public EasyTable CreateTableStructure(string tablename, List <CreateField> columns, uint useTableId, uint[] useColumnId)
        {
            if (useTableId == 0)
            {
                tableId++;
                useTableId = tableId;
            }

            EasyTable table = new EasyTable()
            {
                Id = useTableId, Server = this
            };

            table.Name = tablename;
            int i = 0;

            foreach (CreateField column in columns)
            {
                uint id = 0;
                if (useColumnId == null)
                {
                    columnId++;
                    id = columnId;
                }
                else
                {
                    id = useColumnId[i];
                }
                i++;

                EasyBaseColumn col = null;
                if (column.FieldType == typeof(string))
                {
                    col = new EasyStringColumn()
                    {
                        Id = id
                    }
                }
                ;

                else if (column.FieldType == typeof(int))
                {
                    col = new EasyIntColumn()
                    {
                        Id = id
                    }
                }
                ;

                else if (column.FieldType == typeof(uint))
                {
                    col = new EasyUIntColumn()
                    {
                        Id = id
                    }
                }
                ;

                else if (column.FieldType == typeof(bool))
                {
                    col = new EasyBoolColumn()
                    {
                        Id = id
                    }
                }
                ;

                else if (column.FieldType == typeof(decimal))
                {
                    col = new EasyDecimalColumn()
                    {
                        Id = id
                    }
                }
                ;
                else
                {
                    throw new Exception("Unknown column type! " + column.FieldType);
                }

                col.Name       = column.Name;
                col.IsIdentity = column.IsIdentity;
                table.AddColumn(col);
            }

            Tables.Add(table);

            return(table);
        }