문제

way to map the following to a Dictionary??

Sql sql = new Sql()
.Append("SELECT Count(*) ")
.Append("FROM Custumers")
.Append("WHERE CustomerId = @0", Id)

var result = database.Fetch<Dictionary<int,DateTime>>(sql);

I cannot use List as DateTime is also thr.

도움이 되었습니까?

해결책

Petapoco always return a List<T>, but you can convert the List to a Dictionary afterwards:

var result = database
    .Fetch<Pair<int,DateTime>>(sql)
    .ToDictionary(i => i.ID, i => i.Date);

다른 팁

With NPoco you can write this: it will use the first 2 columns

var result = database.Dictionary<int, DateTime>(sql);

or use what @Eduardo said.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top