本文整理汇总了C#中ITextFormatter.FormatSingular方法的典型用法代码示例。如果您正苦于以下问题:C# ITextFormatter.FormatSingular方法的具体用法?C# ITextFormatter.FormatSingular怎么用?C# ITextFormatter.FormatSingular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextFormatter
的用法示例。
在下文中一共展示了ITextFormatter.FormatSingular方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reference
public string Reference(ForeignKey fk, ITextFormatter formatter)
{
var builder = new StringBuilder();
if (fk.Columns.Count() == 1)
{
var mapList = new List<string>();
mapList.Add("map.Column(\"" + fk.Columns.First().Name + "\")");
// PropertyRef - Used with a FK that doesnt map to a primary key on referenced table.
if (!string.IsNullOrEmpty(fk.Columns.First().ForeignKeyColumnName))
{
mapList.Add("map.PropertyRef(\"" + formatter.FormatText(fk.Columns.First().ForeignKeyColumnName) + "\")");
}
if (fk.Columns.First().IsNullable)
{
mapList.Add("map.NotNullable(true)");
}
mapList.Add("map.Cascade(Cascade.None)");
builder.AppendLine(FormatCode("\t\t\tManyToOne",formatter.FormatSingular(fk.UniquePropertyName),mapList));
}
else
{
// Composite Foreign Key
// eg ManyToOne(x => x.TesteHeader, map => map.Columns(new Action<IColumnMapper>[] { x => x.Name("HeadIdOne"), x => x.Name("HeadIdTwo") }));
if (_language == Language.CSharp)
{
builder.AppendFormat(
"\t\t\tManyToOne(x => x.{0}, map => map.Columns(new Action<IColumnMapper>[] {{ ",
formatter.FormatSingular(fk.UniquePropertyName));
var lastColumn = fk.Columns.Last();
foreach (var column in fk.Columns)
{
builder.AppendFormat("x => x.Name(\"{0}\")", column.Name);
var isLastColumn = lastColumn == column;
if (!isLastColumn)
{
builder.Append(", ");
}
}
builder.Append(" }));");
}
else if (_language == Language.VB)
{
builder.AppendFormat(
"\t\t\tManyToOne(Function(x) x.{0}, Sub(map) map.Columns(new Action<IColumnMapper>[] {{",
formatter.FormatSingular(fk.UniquePropertyName));
var lastColumn = fk.Columns.Last();
foreach (var column in fk.Columns)
{
builder.AppendFormat("x.Name(\"{0}\")", column.Name);
var isLastColumn = lastColumn == column;
if (!isLastColumn)
{
builder.Append(", ");
}
}
builder.Append(" }))");
}
}
return builder.ToString();
}