List <T> GetKeyValuePairs <T>(IDataHolder obj, Func <TableDefinition, T> listCreator) where T : KeyValueListBase { var dataHolderDef = m_mapping.GetDataHolderDefinition(obj.GetType()); var lists = new List <T>(m_mapping.TableDefinitions.Length); for (var i = 0; i < m_mapping.TableDefinitions.Length; i++) { var table = m_mapping.TableDefinitions[i]; for (var j = 0; j < table.ColumnDefinitions.Length; j++) { var col = table.ColumnDefinitions[j]; for (var k = 0; k < col.FieldList.Count; k++) { var field = col.FieldList[k]; var def = field.DataHolderDefinition; if (def == dataHolderDef) { var list = lists.FirstOrDefault(l => l.TableName == table.Name); if (list == null) { lists.Add(list = listCreator(table)); } var value = field.Get(obj); list.AddPair(col.ColumnName, value.ToString()); } } } } return(lists); }
private List <KeyValueListBase> GetWherePairs(IDataHolder obj) { var type = obj.GetType(); var lists = new List <KeyValueListBase>(3); for (var i = 0; i < m_mapping.TableDefinitions.Length; i++) { var table = m_mapping.TableDefinitions[i]; if (table.DataHolderDefinitions.Contains(def => def.Type == type)) { lists.Add(new KeyValueListBase(table, GetWherePairs(table, obj))); } } return(lists); }
private List <KeyValueListBase> GetWherePairs(IDataHolder obj) { Type type = obj.GetType(); List <KeyValueListBase> keyValueListBaseList = new List <KeyValueListBase>(3); for (int index = 0; index < this.m_mapping.TableDefinitions.Length; ++index) { TableDefinition tableDefinition = this.m_mapping.TableDefinitions[index]; if (((IEnumerable <DataHolderDefinition>)tableDefinition.DataHolderDefinitions) .Contains <DataHolderDefinition>((Func <DataHolderDefinition, bool>)(def => def.Type == type))) { keyValueListBaseList.Add(new KeyValueListBase(tableDefinition, this.GetWherePairs(tableDefinition, obj))); } } return(keyValueListBaseList); }
private List <KeyValueListBase> GetWherePairs(IDataHolder obj) { Type type = obj.GetType(); List <KeyValueListBase> keyValueListBaseList = new List <KeyValueListBase>(3); for (int index = 0; index < m_mapping.TableDefinitions.Length; ++index) { TableDefinition tableDefinition = m_mapping.TableDefinitions[index]; if (tableDefinition.DataHolderDefinitions .Contains(def => def.Type == type)) { keyValueListBaseList.Add(new KeyValueListBase(tableDefinition, GetWherePairs(tableDefinition, obj))); } } return(keyValueListBaseList); }
private List <KeyValuePair <string, object> > GetWherePairs(TableDefinition table, IDataHolder obj) { var dataHolderDef = m_mapping.GetDataHolderDefinition(obj.GetType()); var pairs = new List <KeyValuePair <string, object> >(2); foreach (var col in table.PrimaryColumns) { foreach (var field in col.DataColumn.FieldList) { var def = field.DataHolderDefinition; if (def == dataHolderDef) { var value = field.Get(obj); pairs.Add(new KeyValuePair <string, object>(col.Name, value.ToString())); } } } return(pairs); }
/// <summary> /// Deletes the Object from the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitDeleteAndFlush(this IDataHolder obj) { obj.CommitDelete(); ContentMgr.FlushCommit(obj.GetType()); }
/// <summary> /// Deletes the Object from the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitDelete(this IDataHolder obj) { ContentMgr.GetMapper(obj.GetType()).Delete(obj); }
/// <summary> /// Inserts the Object into the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitInsert(this IDataHolder obj) { ContentMgr.GetMapper(obj.GetType()).Insert(obj); }
private List <KeyValuePair <string, object> > GetWherePairs(TableDefinition table, IDataHolder obj) { DataHolderDefinition holderDefinition = this.m_mapping.GetDataHolderDefinition(obj.GetType()); List <KeyValuePair <string, object> > keyValuePairList = new List <KeyValuePair <string, object> >(2); foreach (PrimaryColumn primaryColumn in table.PrimaryColumns) { foreach (IFlatDataFieldAccessor field in primaryColumn.DataColumn.FieldList) { if (field.DataHolderDefinition == holderDefinition) { object obj1 = field.Get(obj); if (obj1 != null) { keyValuePairList.Add( new KeyValuePair <string, object>(primaryColumn.Name, (object)obj1.ToString())); } } } } return(keyValuePairList); }
private List <T> GetKeyValuePairs <T>(IDataHolder obj, Func <TableDefinition, T> listCreator) where T : KeyValueListBase { DataHolderDefinition holderDefinition = this.m_mapping.GetDataHolderDefinition(obj.GetType()); List <T> source = new List <T>(this.m_mapping.TableDefinitions.Length); for (int index1 = 0; index1 < this.m_mapping.TableDefinitions.Length; ++index1) { TableDefinition table = this.m_mapping.TableDefinitions[index1]; for (int index2 = 0; index2 < table.ColumnDefinitions.Length; ++index2) { SimpleDataColumn columnDefinition = table.ColumnDefinitions[index2]; for (int index3 = 0; index3 < columnDefinition.FieldList.Count; ++index3) { IFlatDataFieldAccessor field = columnDefinition.FieldList[index3]; if (field.DataHolderDefinition == holderDefinition) { T obj1 = source.FirstOrDefault <T>((Func <T, bool>)(l => l.TableName == table.Name)); if ((object)obj1 == null) { source.Add(obj1 = listCreator(table)); } object obj2 = field.Get(obj); obj1.AddPair(columnDefinition.ColumnName, (object)obj2.ToString()); } } } } return(source); }
/// <summary> /// Inserts the Object into the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitInsertAndFlush(this IDataHolder obj) { obj.CommitInsert(); FlushCommit(obj.GetType()); }
/// <summary> /// Updates changes to the Object in the underlying Database. /// </summary> public static void CommitUpdateAndFlush(this IDataHolder obj) { obj.CommitUpdate(); FlushCommit(obj.GetType()); }
/// <summary> /// Updates changes to the Object in the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitUpdate(this IDataHolder obj) { GetMapper(obj.GetType()).Update(obj); }
/// <summary> /// Deletes the Object from the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitDelete(this IDataHolder obj) { var mapper = GetMapper(obj.GetType()); mapper.Delete(obj); }
/// <summary> /// Inserts the Object into the underlying Database. /// FlushCommit() needs to be called to persist the operation. /// </summary> public static void CommitInsert(this IDataHolder obj) { var mapper = GetMapper(obj.GetType()); mapper.Insert(obj); }