nHydrate.Generator.Models.Table.GetBasePKColumn C# (CSharp) Method

GetBasePKColumn() private method

private GetBasePKColumn ( Column column ) : Column
column Column
return Column
        public Column GetBasePKColumn(Column column)
        {
            if (column == null)
                throw new Exception("The column cannot be null.");
            if (this.PrimaryKeyColumns.Count(x => x.Name == column.Name) == 0)
                throw new Exception("The column does not belong to this table.");

            var tList = new List<Table>(GetTableHierarchy());
            tList.Add(this);
            return tList.First().PrimaryKeyColumns.FirstOrDefault(x => x.Name == column.Name);
        }

Usage Example

Exemplo n.º 1
0
		private void AppendInsertMapScalar(Table currentTable)
		{
			try
			{
				//Get all columns for all inheritance
				foreach (var currentColumn in _fullHierarchyColumnCache[currentTable])
				{
					if (currentColumn.RelationshipRef == null &&
						!currentColumn.ComputedColumn &&
						!currentColumn.IsReadOnly &&
						(!currentColumn.PrimaryKey || currentTable.GetBasePKColumn(currentColumn).Identity != IdentityTypeConstants.Database))
					{
						//var typeTable = _relatedTypeTableCache[currentColumn];
						//if (typeTable != null)
						//{
						//  sb.AppendLine("						<ComplexProperty Name=\"" + typeTable.PascalName + "\" TypeName=\"" + this.GetLocalNamespace() + ".Entity." + typeTable.PascalName + "Wrapper\">");
						//  sb.AppendLine("							<ScalarProperty Name=\"Value\" ParameterName=\"" + currentColumn.DatabaseName + "\" />");
						//  sb.AppendLine("						</ComplexProperty>");
						//}
						//else
						{
							sb.AppendFormat("						<ScalarProperty Name=\"{0}\" ParameterName=\"{1}\" />", currentColumn.PascalName, currentColumn.DatabaseName).AppendLine();
						}
					}
				}

				if (currentTable.AllowCreateAudit)
				{
					sb.AppendFormat("						<ScalarProperty Name=\"{0}\" ParameterName=\"{1}\" />", _model.Database.CreatedByPascalName, _model.Database.CreatedByDatabaseName).AppendLine();
					sb.AppendFormat("						<ScalarProperty Name=\"{0}\" ParameterName=\"{1}\" />", _model.Database.CreatedDatePascalName, _model.Database.CreatedDateDatabaseName).AppendLine();
				}

				if (currentTable.AllowModifiedAudit)
				{
					sb.AppendFormat("						<ScalarProperty Name=\"{0}\" ParameterName=\"{1}\" />", _model.Database.ModifiedByPascalName, _model.Database.ModifiedByDatabaseName).AppendLine();
				}

			}
			catch (Exception ex)
			{
				throw;
			}
		}
All Usage Examples Of nHydrate.Generator.Models.Table::GetBasePKColumn