服务中定义:
[OperationContract]
public List<Artilce> GetArticlesMethod(int userid)
{
ProcessAllArticlesSelect paas=new ProcessAllArticlesSelect ();
paas.Invoke();
List<Artilce> articles=new List<Artilce> ();
DataTable dt=paas.ResultSet.Tables[0];
var query = from p in dt.AsEnumerable()
where p.Field<int>("UserID") == userid
select new
{ArtilceID=p.Field<int>("ArtilceID"),
ArticleTitle=p.Field<string>("ArticleTitle"),
ArticleContent = p.Field<string>("ArticleContent"),
ArticleInsertDate=p.Field<DateTime>("ArticleInsertDate"),
ArticleTypeID=p.Field<int>("ArticleTypeID"),
ViewPurviewID=p.Field<int>("ViewPurviewID"),
CommentPurviewID=p.Field<int>("CommentPurviewID")};
foreach(var q in query)
{
Artilce ar=new Artilce ();
ar.ArtilceID=q.ArtilceID;
ar.ArticleTitle=q.ArticleTitle;
ar.ArticleContent=q.ArticleContent;
ar.ArticleInsertDate=q.ArticleInsertDate;
ar.ArticleTypeID=q.ArticleTypeID;
ar.ViewPurviewID=q.ViewPurviewID;
ar.CommentPurviewID=q.CommentPurviewID;
articles.Add(ar);
}
return articles.ToList();
在page.xaml.cs中
void proxy_GetArticlesMethodCompleted(object sender, HomeOfBlogger.GetArticles.GetArticlesMethodCompletedEventArgs e){
Articles article1 = new Articles(e.Result.First().ArticleTitle, e.Result.Firs().ArticleContent);
ClearAll.Children.Add(article1);
这里不要像 datagrid.ItemSource=e.Result这样子的
要像上面可以循环传递值的样子、、上面我只取了一个
请问:全部怎么取?就像上面样子的???
}
IList<Article> ars = (IList<Article>)e.Result;
foreach (Article ar in ars) ...