ささいなことですが。

Windowsアプリテスト自動化ライブラリFriendly開発者の日記です。

LambdicSql - α 0.0.14リリース - Nullable 対応

Nullableに対応しました。

www.nuget.org

public class RemunerationNullable
{
    public int id { get; set; }
    public int? staff_id { get; set; }
    public DateTime? payment_date { get; set; }
    public decimal? money { get; set; }
}
public class DBNullable
{
    public Staff tbl_staff { get; set; }
    public RemunerationNullable tbl_remuneration { get; set; }
}

public class SelectDataNullable
{
    public string name { get; set; }
    public DateTime? payment_date { get; set; }
    public decimal? money { get; set; }
}

public void Nullable()
{
    var query = Sql<DBNullable>.Create(db =>
        Select(new SelectDataNullable()
        {
            name = db.tbl_staff.name,
            payment_date = db.tbl_remuneration.payment_date,
            money = db.tbl_remuneration.money,
        }).
        From(db.tbl_remuneration).
            Join(db.tbl_staff, db.tbl_remuneration.staff_id == db.tbl_staff.id).
            Where(db.tbl_remuneration.money != null));

    //文字列化
    Debug.Print(query.ToSqlInfo(typeof(SqlConnection)).SqlText);

    //Dapperを使っているなら、以下のように実行できます
    var datas = _connection.Query(query).ToList();
}
SELECT
tbl_staff.name AS name,
	tbl_remuneration.payment_date AS payment_date,
	tbl_remuneration.money AS money
FROM tbl_remuneration
	JOIN tbl_staff ON (tbl_remuneration.staff_id) = (tbl_staff.id)
WHERE (tbl_remuneration.money) <> (NULL)

履歴

2016/09/02 β版対応