public void BindSimpleValue(HbmManyToOne manyToOneMapping, string propertyPath, bool isNullable) { ColumnsBinder binder = new ColumnsBinder(value, Mappings); object[] columnsAndFormulas = manyToOneMapping.ColumnsAndFormulas.ToArray(); if (columnsAndFormulas.Length > 0) { this.AddColumnsAndOrFormulas(binder, columnsAndFormulas, isNullable); } else { // No formulas or columns, so add default column binder.Bind(new HbmColumn() { name = mappings.NamingStrategy.PropertyToColumnName(propertyPath), notnull = manyToOneMapping.notnull, notnullSpecified = manyToOneMapping.notnullSpecified, unique = manyToOneMapping.unique, uniqueSpecified = true, uniquekey = manyToOneMapping.uniquekey, index = manyToOneMapping.index }, isNullable); } }
private void BindColumnsAndFormulas(object[] columnsAndFormulas, bool isNullable, Func <HbmColumn> defaultColumnDelegate) { var binder = new ColumnsBinder(value, Mappings); if (columnsAndFormulas.Length > 0) { foreach (var item in columnsAndFormulas) { switch (item) { case HbmFormula formula: BindFormula(formula); break; case HbmColumn column: binder.Bind(column, isNullable); break; } } } else { // No formulas or columns, so add default column binder.Bind(defaultColumnDelegate(), isNullable); } }
/// <summary> /// Bind columns and formulas in the order in which they were mapped. /// </summary> /// <param name="binder"></param> /// <param name="columnsAndFormulas"></param> /// <param name="isNullable"></param> private void AddColumnsAndOrFormulas(ColumnsBinder binder, object[] columnsAndFormulas, bool isNullable) { foreach (object item in columnsAndFormulas) { if (item.GetType() == typeof(HbmFormula)) { this.BindFormula((HbmFormula)item); } if (item.GetType() == typeof(HbmColumn)) { binder.Bind((HbmColumn)item, isNullable); } } }
/// <summary> /// Bind columns and formulas in the order in which they were mapped. /// </summary> /// <param name="binder"></param> /// <param name="columnsAndFormulas"></param> /// <param name="isNullable"></param> private void AddColumnsAndOrFormulas(ColumnsBinder binder, object[] columnsAndFormulas, bool isNullable) { foreach (object item in columnsAndFormulas) { if (item.GetType() == typeof(HbmFormula)) this.BindFormula((HbmFormula)item); if (item.GetType() == typeof(HbmColumn)) binder.Bind((HbmColumn)item, isNullable); } }