本文整理汇总了C#中TableName.ToClassName方法的典型用法代码示例。如果您正苦于以下问题:C# TableName.ToClassName方法的具体用法?C# TableName.ToClassName怎么用?C# TableName.ToClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableName
的用法示例。
在下文中一共展示了TableName.ToClassName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Linq2SQLClassBuilder
public Linq2SQLClassBuilder(string ns, Command cmd, TableName tname, Dictionary<TableName, TableSchema> schemas)
: base(ns, cmd)
{
this.tname = tname;
this.cname = tname.ToClassName(null);
this.schemas = schemas;
builder.AddUsing("System");
//builder.AddUsing("System.Collections.Generic");
//builder.AddUsing("System.Data");
builder.AddUsing("System.Data.Linq");
builder.AddUsing("System.Data.Linq.Mapping");
}
示例2: 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;
}