C# 4.0 映射到PetaPoco中的字典集合?

C# 4.0 映射到PetaPoco中的字典集合?,c#-4.0,petapoco,C# 4.0,Petapoco,将以下内容映射到词典的方法 Sql sql = new Sql() .Append("SELECT Count(*) ") .Append("FROM Custumers") .Append("WHERE CustomerId = @0", Id) var result = database.Fetch<Dictionary<int,DateTime>>(sql); Sql=newsql() .Append(“选择计数(*)) .附加(“来自客户”) .Append(

将以下内容映射到词典的方法

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

var result = database.Fetch<Dictionary<int,DateTime>>(sql);
Sql=newsql()
.Append(“选择计数(*))
.附加(“来自客户”)
.Append(“其中CustomerId=@0”,Id)
var result=database.Fetch(sql);

我不能使用列表,因为DateTime也是thr。

Petapoco始终返回一个
列表
,但您可以在以后将列表转换为字典:

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

对于NPoco,您可以这样写:它将使用前两列

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

或者用@Eduardo说的话。

在这种情况下,配对是什么?KeyValuePair不工作