私はdapperを使用していますが、私は7種類以上のマッピングを持っています。7種類以上のマッピングされたDapper Multimapping、System.ArgumentException
私はdapperの方法IEnumerable<TReturn> Query<TReturn>(this IDbConnection cnn, string sql, Type[] types, Func<object[], TReturn> map, [Dynamic] dynamic param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
が存在することを知っているし、そこに非常に良い例との回答hereはあるが、私は私の場合には解決できません。
ようポコ
Table Poi(
Id,
Date,
LineId FK Line table,
TrackId FK Track table,
State_Id FK State table,
Type_Id FK Type table,
Category_Id FK Category table,
Processing_Id FK Processing table,
Vehicle_Id FK Vehicle table,
SystemId FK System table,
UnitId FK Unit table,
Speed)
このテーブルを持っているとします
class Poi
{
public long Id { get; set; }
public DateTime Date { get; set; }
public float Speed { get; set; }
public State State { get; set; }
public Type PoiType { get; set; }
public Category Category { get; set; }
public Processing Processing { get; set; }
public Vehicles Vehicle { get; set; }
public Line Line { get; set; }
public Track Track { get; set; }
public System System { get; set; }
public Unit Unit { get; set; }
}
と私は呼んで添付返信、に基づいて、このSQLクエリ今
select select poi.*, ps.Id, ps.Name, pt.name,pt.id,pc.id,pc.name,pc.issystem,processing.id,processing.name,processing.date, v.name,v.id,
t.id,t.name,t.code, ds.name, ds.id, du.id, du.name from Poi poi
left join State ps on poi.State_Id = ps.Id
left join Type pt on poi.PoiType_Id = pt.Id
left join Category pc on poi.Category_Id = pc.Id
left join Processing processing on poi.Processing_Id = processing.Id
left join Vehicles v on poi.Vehicle_Id = v.Id
left join Line l on poi.LineId = l.Id
left join Track t on poi.TrackId = t.Id
left join DiagSystem ds on poi.SystemId = ds.Id
left join DiagUnit du on poi.UnitId = du.Id
を持っていると仮定このパラメータを持つメソッド
connection.Query<Poi>(sql,
new[]
{
typeof(Poi),
typeof(State),
typeof(Type),
typeof(Category),
typeof(Processing),
typeof(Vehicles),
typeof(Line),
typeof(Track),
typeof(System),
typeof(Unit)
},
objects =>
{
Poi poi = objects[0] as Poi;
State ps = objects[1] as State;
Type pt = objects[2] as Type;
Category pc = objects[3] as Category;
Processing processing = objects[4] as Processing;
Vehicles v = objects[5] as Vehicles;
Line l = objects[6] as Line;
Track t = objects[7] as Track;
System ds = objects[8] as System;
Unit du = objects[9] as Unit;
poi.State = ps;
poi.Type = pt;
poi.Category = pc;
poi.Processing = processing;
poi.Vehicle = v;
poi.Line = l;
poi.Track = t;
poi.System = ds;
poi.Unit = du;
return poi;
},
new { Value = value }
,splitOn: "State_Id,PoiType_Id,Category_Id,Processing_Id,Vehicle_Id,LineId,TrackId,SystemId,UnitId"
).ToList();
しかし、私はmultimappingについて、同じエラーを受信し続ける:
をDapper.dll
の 'System.ArgumentExceptionの'追加情報:multimapping APIを使用している場合は、設定 確保splitOn param id以外のキーがある場合
splitonパラメータにエラーがあると思いますか?わかりません!
あなたは 'select *'を試しましたか? –
はい、問題は同じです – pask23