首页 新闻 会员 周边 捐助

wcf返回值问题

0
[已解决问题] 解决于 2009-02-12 10:58

服务中定义:

[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这样子的

要像上面可以循环传递值的样子、、上面我只取了一个

请问:全部怎么取?就像上面样子的???
        }

越~、。的主页 越~、。 | 初学一级 | 园豆:0
提问于:2009-01-06 20:09
< >
分享
最佳答案
0

IList<Article> ars = (IList<Article>)e.Result;

foreach (Article ar in ars) ...

Gray Zhang | 专家六级 |园豆:17610 | 2009-01-06 22:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册