Tag: ria

执行SQL查询WCF RIA Silverlight

我创建了一个数据库,将其与我的Silverlight应用程序中的DomainService相关联。 现在,我希望能够通过使用该服务执行某些操作,例如注册,登录等。 我怎么能这样做。 我有在服务中创建的预设方法,例如InsertUser,但它只需要一个参数,所以我不确定它是如何工作的。 在元数据中我有所有字段等。 有人可以帮我从这里出去吗。 谢谢。 public IQueryable GetUsers() { return this.ObjectContext.Users; } public void InsertUser(User user) { if ((user.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(user, EntityState.Added); } else { this.ObjectContext.Users.AddObject(user); } } 对于检索我使用的用户(作为TBohnen.jnr代码的基础): UserContext _userContext = new UserContext(); public MainPage() { InitializeComponent(); LoadOperation loGetUsers = _userContext.Load(_userContext.GetUsersQuery()); loGetUsers.Completed += new EventHandler(loGetUsers_Completed); } void loGetUsers_Completed(object sender, EventArgs […]

RIA服务:包括选择(许多)不工作

我有两种实体类型: Document (有一个Customer )和Customer (有一个Collection Documents ) 我的疑问是根据客户的姓名或号码为客户提供文件。 查询如下所示: public IQueryable GetCustomerDocuments(DateTime startDate, DateTime endDate, string filterText) { return this.ObjectContext.Customers .Where(c => c.CustomerName.Contains(filterText) || c.CustomerNumber.Contains(filterText)) .SelectMany(c => c.Documents) .Where(d => d.Date >= startDate && d.Date <= endDate); } 当查询返回时,我希望它包含Document和Customer实体…. 我已经尝试了我能想到的一切,包括Include(“Documents.Customer”) , Include(“Customer”)等。 我肯定在元数据中设置了IncludeAttribute 。 思考? 这有可能吗? 谢谢!

WCF RIA服务 – 加载多个实体

我正在寻找一种解决以下问题的模式,我认为这种模式很常见。 我正在使用WCF RIA Services在初始加载时将多个实体返回给客户端。 我希望两个实体都异步加载,以免锁定UI,我想利用RIA Services来做到这一点。 我的解决方案似乎在下面。 我会用这种方法遇到问题/限制吗? 这有更好的模式吗? 谢谢! //create proxy to Domain Service var proxy = new RIAService.Web.DomainContext(); //call service; fire event when Presentation entities have been returned var loadPresentations = proxy.Load(proxy.GetPresentationsQuery()); loadPresentations.Completed += new EventHandler(loadPresentations_Completed); //call service; fire event when Topics entities have been returned var loadTopics = proxy.Load(proxy.GetTopicsQuery()); loadTopics.Completed += new […]

无法通过RIA服务访问EntityObject类型

我的entity framework模型是从SQL Server数据库生成的。 由于我需要从Silverlight访问数据库,因此我针对EF模型为RIAServices生成了一个DomainService。 Product是与表Product对应的自动生成的EntityObject之一。 我试图将自定义类CompositeData传递给Silverlight客户端,如图所示。 问题是客户端无法访问CurrentProduct字段,但可以访问其他字符串/ int字段。 如何使CurrentProduct可以从客户端访问? public class CompositeData { [Key] public Guid PKey { get; set; } public string CompositeName { get; set; } public string Identity { get; set; } public Product CurrentProduct { get; set; } //Product is an auto-generated EntityObject class public CompositeData() { PKey = Guid.NewGuid(); } […]