我正在制作Silverlight WCF RIA Services应用程序。虽然,我卡住尝试不同的方式来使用数据库中的多个表。 目前,我试图加入域服务类中的表并将其返回给服务代理。我开始从位于模板项目: http://simplemvvmtoolkit.codeplex.com/wikipage?title=WCF%20RIA%20ServicesWCF RIA服务,加入域服务中的表
我想加盟像表:
public IQueryable<Invoice> GetInvoices()
{
return (from i in this.ObjectContext.Invoices
join o in this.ObjectContext.otherTable equals condition
join s in this.ObjectContext.otherTable equals condition
select i);
}
此连接的基础上正确的给定条件的表。但我实际上需要从两个i.Invoices表& s.otherTable的项目字段。 任何建议,使此投影在DomainServiceClass.cs中工作?
示例代码USER“克里斯”建议:
public class Invoice_PM
{
[Key]
public int InvoiceId { get; set; }
public string PaymentNum { get; set; }
public DateTime? PaymentExpDate { get; set; }
public DateTime? InvoiceDateTime { get; set; }
[Include, Association("name", "InvoiceID", "InvoiceDateTime")]
public IEnumerable<InvoiceSoldToShipTo_PM> SoldToShipTo { get; set; }
}
当我尝试这种做法时,会出现一个返回的构建错误。 “不一致的可访问性:返回类型”我相信这是因为生成的域服务方法与GetInvoices()方法有关。那么我怎样才能应用这些更新,删除和插入功能? – jammer 2012-03-12 13:22:45
链接到编译错误:http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=zh-CN&k=k(CS0050);k(VS.ERRORLIST)&rd=true – jammer 2012-03-12 15:48:25
请勿使用生成的方法返回新类型的集合,将生成的方法设置回原来的样子,返回类型为IQueryable,然后手动创建一个类似GetCustomInvoices的新方法,返回类型为IQueryable 。我认为这应该解决您的问题,因为我的域服务中的自定义方法返回自定义类型。 –
Chris
2012-03-12 16:16:25