DNN 5.5.0にアップグレードした後IHydratable
、すべてのビジネスオブジェクトに実装する必要がありました。
このアイデアは最初は良い方法のように思えましたが、遊んだ後はIHydratable
もうよくわかりません。
2つの可能性があります:
- 私はそれを間違っています
IHydratable
select *
すべてのクエリを作成するために使用するように強制します
ビジネスケース:
- 私の最初のsprocはと
BgId
を返しますBgShortDesc
- 2番目のsprocが返さ
BgId
れ、BgReportedUser
私IHydratable
は以下のように実装されています:
public class Bug : IHydratable
{
public int BgId { get; set; }
public string BgShortDesc { get; set; }
public int BgReportedUser { get; set; }
public DateTime BgReportedDate { get; set; }
public Bug() { }
public int KeyID
{
get { return BgId; }
set { BgId = value; }
}
public void Fill(IDataReader dr)
{
BgId = Convert.ToInt32(Null.SetNull(dr["BgId"], BgId));
BgShortDesc = Convert.ToString(Null.SetNull(dr["BgShortDesc"], BgShortDesc));
BgReportedUser = Convert.ToInt32(Null.SetNull(dr["BgReportedUser"], BgReportedUser));
BgReportedDate = Convert.ToDateTime(Null.SetNull(dr["BgReportedDate"], BgReportedDate));
}
}
すべてのフィールドが。で返されるわけではないため、fillメソッドはIndexOutOfRangeException
上記のsprocのいずれかにをスローしIDataReader
ます。
問題を回避する簡単な方法はselect *
、すべてのsprocで使用することですが、それは良い習慣ではありません。
IHydratable
このシナリオで実装する適切な方法は何ですか?
PSは、私の例は、要点を理解するために単純化しすぎていることを覚えておいてください。