に順位割り当て:私は先のコレクションオブジェクトにソースのコレクションオブジェクトをマップしようとしていますAutomapper - Destinationオブジェクト
public class Source
{
public string Value1{ get; set; }
}
public class Destination
{
public string Value1{ get; set; }
public int Ranking { get; set; }
}
。私のソースコレクションは、このようなものです:
var source = new List<Source>();
source.Add(new Source(){ Value1= "test1" });
source.Add(new Source(){ Value1= "test2" });
先のオブジェクトのランキングの属性は、ソースコレクション内の項目のインデックスに対応していなければならない場合、私はマッパーを書くことができますどのように?
I.e.マッピング後、Value1 = "test1"
のSource
の行き先ランキングは1
となり、次は2
となります。マップアクションの前後
なぜこのようなことをしたいですか?それは1つの大きなコードのにおいです。 AutoMapperソリューションを探すのではなく、このコードを簡単にするようにしてください。 –
私はAutomapperが提供しているものがあることを知りたかったのです。私はリストを反復して値をマップしたくなかった –