如何在silverlight中从WCF域服务类方法将数据添加到另一个类?
您好,我正在 Silverlight 中使用 WCF RIA 服务类。
我确实有一个名为 mcChart
的折线图控件,其中我已将项目源绑定到 customer< 类的
Date
和 Amount
属性/代码>。
public class Customer
{
public DateTime Date{ get; set; }
public int Amount{ get; set; }
}
我确实有通过 WCF ria 域服务类访问 sql 表 gardenwater{Id, Date, Amt}
的方法:
public IQueryable<gardenwater> GetGardenwaters()
{
return this.ObjectContext.gardenwaters;
}
现在我想将数据存储在 List
以便可以在图表中显示。
我已经尝试过这样的:
EntityQuery<gardenwater> inquery = from c in wdc.GetGardenwatersQuery()
select new { Date =Convert.ToDateTime(c.Date), Amount =Convert.ToInt32(c.usedwater) };
然后
foreach (var gardenWater in inquery )
{
cust.Add(new Customer() { Date = Convert.ToDateTime(gardenWater.Date), Amount = Convert.ToInt32(gardenWater.usedwater) });
}
mcChart.DataContext = cust;
执行上述所有操作我无法得到任何好的结果。
我想通过在类属性中存储SQL表数据来显示数据。
请建议我可以做什么或我犯了什么错误?
Hi i am using WCF RIA services class in Silverlight.
I do have a line chart control named mcChart
in which i have bound the item source to Date
and Amount
properties of class customer
.
public class Customer
{
public DateTime Date{ get; set; }
public int Amount{ get; set; }
}
I do have this method through WCF ria domain service class to access the sql table gardenwater{Id, Date, Amt}
:
public IQueryable<gardenwater> GetGardenwaters()
{
return this.ObjectContext.gardenwaters;
}
Now i want to store the data in List<Customer> cust = new List<Customer>();
so that it can be shown in the chart.
I have tried like this :
EntityQuery<gardenwater> inquery = from c in wdc.GetGardenwatersQuery()
select new { Date =Convert.ToDateTime(c.Date), Amount =Convert.ToInt32(c.usedwater) };
and then
foreach (var gardenWater in inquery )
{
cust.Add(new Customer() { Date = Convert.ToDateTime(gardenWater.Date), Amount = Convert.ToInt32(gardenWater.usedwater) });
}
mcChart.DataContext = cust;
Doing all the above i am not able to get any good results.
I want to display the data through storing SQL table data in Class properties.
Please suggest me what can i do or what mistakes i am doing ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在已经解决了...我可以使用以下
I got it resolved by now...i can use following