silverlight3 中使用ria后,怎么修改DomainService.cs等等

ericloot 2010-01-13 04:20:26
DomainService1.cs:

[EnableClientAccess()]
public class DomainService1 : LinqToEntitiesDomainService<CoachCRMDBEntities>
{


// TODO: Consider
// 1. Adding parameters to this method and constraining returned results, and/or
// 2. Adding query methods taking different parameters.
public IQueryable<Schedule> GetSchedule()
{
return this.Context.Schedule;
}

public void InsertSchedule(Schedule schedule)
{
this.Context.AddToSchedule(schedule);
}

public void UpdateSchedule(Schedule currentSchedule)
{
this.Context.AttachAsModified(currentSchedule, this.ChangeSet.GetOriginal(currentSchedule));
}

public void DeleteSchedule(Schedule schedule)
{
if ((schedule.EntityState == EntityState.Detached))
{
this.Context.Attach(schedule);
}
this.Context.DeleteObject(schedule);
}


}


page.xaml:
<riaServices:DomainDataSource x:Name="DDS"
AutoLoad="True"
QueryName="GetScheduleQuery"
LoadedData="DDS_LoadedData">
<riaServices:DomainDataSource.DomainContext>
<localWeb:DomainService1/>
</riaServices:DomainDataSource.DomainContext>
</riaServices:DomainDataSource>

page.xaml.cs:

private void DDS_LoadedData(object sender, LoadedDataEventArgs e)
{


var myAppts = e.Entities;
.......
}

数据库的表名Schedule,有字段personID(非主键)
DomainService1.cs是自动生成的,但是只能最简单的增删改查,已成功
我现在想查personID符合记录,不知道该怎么做,还有增删改等等..
...全文
177 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tagduck 2010-05-17
  • 打赏
  • 举报
回复
dfsadf
jv9 2010-01-14
  • 打赏
  • 举报
回复
我记得过去写过一个RIA例程,在家里电脑上,晚上可以传给你。其实很简单,只要你熟悉LINQ,就是把例程转换一下。推荐你看看:

http://blogs.msdn.com/brada/default.aspx

Brad的博客,他是微软RIA的开发人员,他推出的教程很不错。都有代码下载参考。
ericloot 2010-01-14
  • 打赏
  • 举报
回复
先谢谢搂上的,我正在看.但是不是很明白.
我改了DomainService1.cs,现在可以只获取personID =1的记录
public IQueryable<Schedule> GetSchedule()
{
// return this.Context.Schedule;
return from r in Context.Schedule
where r. personID == 1
select r;

}

继续改
public IQueryable<Schedule> GetSchedule(int personId)
{
return this.Context.Schedule;
//return from r in Context.Schedule
// where r. personId == personId
// select r;

}


再就不知道怎么将参数传过去了...

8,734

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧