これはこの問題を解決するための最良の方法だとは言いませんが、これが私のやり方です。私は、BoundField aspコントロールへのバインディングのために、プレーンテキストで列名を取得する必要があり、それはEFテンプレートに焼き付けられませんでした。
私はこの単純なプロパティをロードするだけのコードを追加しました。つまり、カラム名は、私がそれを可能にするためです。 "Column"という名前の "table"オブジェクトに構造体を追加し、列名をconst文字列として公開します。
:このようなコードを作成します
<#
EndNamespace(code);
}
:
<#
if (simpleProperties.Any())
{
#>
public struct ColumnName
{
<#
foreach (var simpleProperty in simpleProperties)
{
#>
public const string <#= simpleProperty #> = "<#= simpleProperty #>";
<#
}
#>
}
<# }
#>
}
私は、溶液中EDMXファイルの下で個々のファイルを生成しT4テンプレート内のコードのこのビット前にこれを置い
public partial class JobPosting
{
public int PositionRowId { get; set; }
public System.Guid PositionRelatedGuid { get; set; }
public struct ColumnName
{
public const string PositionRowId = "PositionRowId";
public const string PositionRelatedGuid = "PositionRelatedGuid";
}
}
私はこれが役に立ちそうです。
私はedmProperty.Nameはあなたが意味するものではないと仮定しています。基になる列名が必要です。 – Maarten
@Maarten - 正しい。 – Bobson