MVC .netプロジェクトでAmazon AWSでDynamoDBを使用しようとしています。また、Business-DataAccess-Modelレイヤープロジェクトもやっています。TオブジェクトをAmazon DynamoDBドキュメントに動的に変換する方法
私はAdd()機能を実装するGenericDataRepositoryクラスを持っています。
Add()にTオブジェクトを送信しています。そのオブジェクトをAmazonのDocumentオブジェクトに動的に変換したいと思います。どのようにすればよいのでしょうか?ベストプラクティスは何ですか?動的に文書を埋めるため
public void Add(T entity)
{
if (entity == null)
return;
var doc = new Document();
// Convert entity to Document automatically
doc["Title"] = entity.Title;
doc["Body"] = entity.Body;
doc["Author"] = entity.Author;
// Convert entity to Document automatically
.....
.....
.....
}
変換が多すぎるため、結果として動作が遅くなります。 –
はい、しかし、純粋な手動の反射は、オブジェクトがサブオブジェクト、コレクションなどとなる可能性があるため複雑になります。 – Sergey