本文整理汇总了C#中Class.MakeUniqueName方法的典型用法代码示例。如果您正苦于以下问题:C# Class.MakeUniqueName方法的具体用法?C# Class.MakeUniqueName怎么用?C# Class.MakeUniqueName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class
的用法示例。
在下文中一共展示了Class.MakeUniqueName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEntitySet
/// <summary>
/// add children tables
/// </summary>
/// <param name="clss"></param>
/// <param name="constructor"></param>
/// <param name="key"></param>
/// <returns></returns>
private Property AddEntitySet(Class clss, Constructor constructor, IForeignKey key)
{
TableName fk_tname = new TableName(tname.DatabaseName, key.FK_Schema, key.FK_Table);
string fk_cname = fk_tname.ToClassName(null);
string pname;
Property prop;
TypeInfo ty;
Field field;
var fk_schema = GetSchema(fk_tname);
var _keys = fk_schema.PrimaryKeys.Keys;
if (_keys.Length == 1 && _keys.Contains(key.FK_Column))
{
// 1:1 mapping
pname = clss.MakeUniqueName(Pluralization.Singularize(fk_cname));
ty = new TypeInfo { userType = $"EntityRef<{fk_cname}>" };
field = new Field(ty, $"_{pname}") { modifier = Modifier.Private };
prop = new Property(new TypeInfo { userType = fk_cname }, pname) { modifier = Modifier.Public };
prop.gets.Append($"return this._{pname}.Entity;");
prop.sets.Append($"this._{pname}.Entity = value;");
prop.AddAttribute(new AttributeInfo("Association",
new
{
Name = $"{this.cname}_{fk_cname}",
Storage = $"_{pname}",
ThisKey = key.PK_Column,
OtherKey = key.FK_Column,
IsUnique = true,
IsForeignKey = false
}));
}
else
{
//1:n mapping
pname = clss.MakeUniqueName(Pluralization.Pluralize(fk_cname));
constructor.statements.AppendLine($"this._{pname} = new EntitySet<{fk_cname}>();");
ty = new TypeInfo { userType = $"EntitySet<{fk_cname}>" };
field = new Field(ty, $"_{pname}") { modifier = Modifier.Private };
prop = new Property(ty, pname) { modifier = Modifier.Public };
prop.gets.Append($"return this._{pname};");
prop.sets.Append($"this._{pname}.Assign(value);");
prop.AddAttribute(new AttributeInfo("Association",
new
{
Name = $"{this.cname}_{fk_cname}",
Storage = $"_{pname}",
ThisKey = key.PK_Column,
OtherKey = key.FK_Column,
IsForeignKey = false
}));
}
clss.Add(field);
return prop;
}
示例2: AddEntityRef
/// <summary>
/// add foreighn keys
/// </summary>
/// <param name="clss"></param>
/// <param name="key"></param>
/// <returns></returns>
private Property AddEntityRef(Class clss, IForeignKey key)
{
string pk_cname = new TableName(tname.DatabaseName, key.PK_Schema, key.PK_Table).ToClassName(null);
string pname = clss.MakeUniqueName(pk_cname);
var field = new Field(new TypeInfo { userType = $"EntityRef<{pk_cname}>" }, $"_{pname}") { modifier = Modifier.Private };
clss.Add(field);
var prop = new Property(new TypeInfo { userType = pk_cname }, pname) { modifier = Modifier.Public };
prop.gets.Append($"return this._{pname}.Entity;");
prop.sets.Append($"this._{pname}.Entity = value;");
prop.AddAttribute(new AttributeInfo("Association",
new
{
Name = $"{pk_cname}_{this.cname}",
Storage = $"_{pname}",
ThisKey = key.FK_Column,
OtherKey = key.PK_Column,
IsForeignKey = true
}));
return prop;
}