1

Where the webservice returns a DataTable, is it even possible?

All the samples reference a db/Connection object.

Any pointers are appreciated.

Thanks!

4

1 に答える 1

3

DataTable を返す必要はありません。これは ADO.NET の考え方です。代わりに、pocos (データを表すクラス) のリストを返すことができます。Topten Software の Petapoco ヘルプ ページの例を次に示します。

// Create a PetaPoco database object
var db=new PetaPoco.Database("connectionStringName");

// Show all articles    
foreach (var a in db.Query<article>("SELECT * FROM articles"))
{
    Console.WriteLine("{0} - {1}", a.article_id, a.title);
}

この例では、「記事」は次のような単純な c# オブジェクトです。

public class article
{
    public long article_id { get; set; }
    public string title { get; set; }
    public DateTime date_created { get; set; }
    public bool draft { get; set; }
    public string content { get; set; }
}
于 2012-02-28T22:00:08.930 に答える