S#arp ArchitectureはT4を使用して足場発生器を含みます。テンプレートモデル定義からモデル、ビュー、コントローラ、およびテストを生成します。あなたはフルCRUDを取得します。 T4(Visual Studioのテンプレート言語だと思います)を使用しているので、必要に応じてデフォルトのテンプレートを拡張できます。
は、ここではテンプレートの例です:
EntityScaffoldingDetails entityScaffoldingDetails =
new EntityScaffoldingDetails("Organization.Worker");
/*
* Property names should be PascalCase.
* Do not include a property for Id as it will be included automatically.
*/
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("FirstName", "string", "Joe", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("LastName", "string", "Smith", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("BirthDate", "DateTime", DateTime.Parse("1/1/1975"))
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("Manager", "Employee", null, "[NotNull]")
);
///////////////////////////////////////////////////
// The first parameter should reflect the root directory of your solution
//ScaffoldingGenerator generator = new ScaffoldingGenerator(
//@"D:\Work\Project\", "Orders", entityScaffoldingDetails);
// Uncomment this line when you're ready for the scaffolding generator to fire...be sure to recomment after it completes to avoid accidental generating!
//generator.Run();
一つの小さな加え:例えば、私はViewModelにで動作するようにコントローラを好む、ので、私はは、エンティティ、そのままそれを使用していないお勧めしません。私は足場をあまり使わない。しかし、あなたはT4を学ぶ必要があるかもしれませんが、かなり柔軟です。
私はJon Skeetが優れたコードジェネレータであることがわかりました。 –