public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); IColumnModel column = databaseContext.Column; string TrimedStringContext = TrimContextFromContextWrapper(StringContext); if (!TrimedStringContext.Equals("")) { throw new Exception($"There is a problem with the provided StringContext :'{StringContext}' to the suited word '{Signature}'"); } if (databaseContext.Table == null) { return(ZeroIndexAsString); } int currentIndex = ZeroIndex; int currentAutoIndex = ZeroIndex; IList <IColumnModel> columnList = databaseContext.Table.Columns; for (currentIndex = 0; currentIndex < columnList.Count; currentIndex++) { IColumnModel currentColumn = columnList[currentIndex]; if (currentColumn.IsNotNull) { if (currentColumn.Equals(column)) { return(Convert.ToString(currentAutoIndex)); } currentAutoIndex++; } } return(ZeroIndexAsString); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); IColumnModel column = databaseContext.Column; string TrimedStringContext = TrimContextFromContextWrapper(StringContext); if (databaseContext.Table == null) { throw new Exception("The provided column has no parent table"); } IList <IColumnModel> columnList = databaseContext.Table.Columns; if (columnList == null || !(columnList.Count > 0)) { throw new Exception("The provided column's parent table has no column associated to"); } IColumnModel currentLastPrimaryColumn = null; foreach (IColumnModel currentColumn in columnList) { if (!currentColumn.IsPrimaryKey) { currentLastPrimaryColumn = currentColumn; } } if (currentLastPrimaryColumn == null) { return(""); } if (!currentLastPrimaryColumn.Equals(column)) { return(""); } return(HandleTrimedContext(TrimedStringContext, databaseContext)); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { if (databaseContext == null) { throw new ArgumentNullException(nameof(databaseContext)); } if (StringContext == null) { throw new Exception($"The provided {nameof(StringContext)} is null"); } IColumnModel columnModel = databaseContext.Column; if (columnModel == null) { throw new Exception($"The {nameof(columnModel)} is not set"); } string TrimedStringContext = TrimContextFromContextWrapper(StringContext); if (databaseContext.Table == null) { throw new Exception("The provided column has no parent table"); } IList <IColumnModel> columnList = databaseContext.Table.Columns; if (columnList == null || !(columnList.Count > 0)) { throw new Exception("The provided column's parent table has no column associated to"); } if (columnModel.Equals(columnList[(columnList.Count - 1)])) { return(HandleTrimedContext(TrimedStringContext, databaseContext)); } else { return(""); } }