//--------------------------------------------------------------------- void _loadTable(string table_name, List <EbFieldInfo> list_fieldinfo) { EbTable table = new EbTable(); table.Name = table_name; foreach (var i in list_fieldinfo) { switch (i.FieldType) { case EbFieldType.Int: // int { PropDef prop_def = new PropDef(i.FieldName, typeof(int)); table._addPropDef(prop_def); } break; case EbFieldType.Float: // float { PropDef prop_def = new PropDef(i.FieldName, typeof(float)); table._addPropDef(prop_def); } break; case EbFieldType.String: // string { PropDef prop_def = new PropDef(i.FieldName, typeof(string)); table._addPropDef(prop_def); } break; default: break; } } string str_query_select = string.Format("SELECT * FROM {0};", table_name); SQLiteQuery qr; qr = new SQLiteQuery(mSqliteDb, str_query_select); while (qr.Step()) { EbPropSet prop_set = new EbPropSet(); foreach (var i in list_fieldinfo) { bool is_null = qr.IsNULL(i.FieldName); if (is_null) { prop_set._addProp(i.FieldName, null); continue; } switch (i.FieldType) { case EbFieldType.Int: // int { PropDef prop_def = table.getPropDef(i.FieldName); Prop <int> prop = new Prop <int>(prop_def, 0); prop.set(qr.GetInteger(i.FieldName)); prop_set._addProp(i.FieldName, prop); } break; case EbFieldType.Float: // float { PropDef prop_def = table.getPropDef(i.FieldName); Prop <float> prop = new Prop <float>(prop_def, 0f); prop.set((float)qr.GetDouble(i.FieldName)); prop_set._addProp(i.FieldName, prop); } break; case EbFieldType.String: // string { PropDef prop_def = table.getPropDef(i.FieldName); Prop <string> prop = new Prop <string>(prop_def, ""); prop.set(qr.GetString(i.FieldName)); prop_set._addProp(i.FieldName, prop); } break; default: break; } } IProp prop_id = prop_set.getProp("Id"); if (prop_id == null) { EbLog.Error("EbDataMgr1._loadTable() Error! Key=Id not exist, TableName=" + table_name); continue; } Prop <int> p = (Prop <int>)prop_id; prop_set.Id = p.get(); table._addPropSet(prop_set); } qr.Release(); mDb._addTable(table); }
//--------------------------------------------------------------------- internal void _addPropSet(EbPropSet prop_set) { mMapPropSet[prop_set.Id] = prop_set; }