开发者

.NET RIA services metadata and foreign keys

开发者 https://www.devze.com 2022-12-15 19:28 出处:网络
I’m using Silverlight and the .NET RIA Services. I’ve generated an entity data model from a database, created one domain class service for all the tables and chosen to generate the metadata.

I’m using Silverlight and the .NET RIA Services.

I’ve generated an entity data model from a database, created one domain class service for all the tables and chosen to generate the metadata.

Now, when trying to build I get errors in metadata that contain foreign keys in the generated file App.Web.g.cs. The problem is there are lots of evaluations comparing Entities to simple values. For example, Order.Customer is a foreign key for Customer.ID and the following fails:

private bool FilterOrder(Order entity)开发者_如何学JAVA { return (entity.Customer == this.ID); }

I would expect to see:

private bool FilterOrder(Order entity) { return (entity.Customer.ID == this.ID); }

I don’t really know what to do here as the problem is in a generated file. Any help would be appreciated.

Thanks


I think you have to explicitly create the foreign key as a Scalar Property of your Order entity and then mark it as the Dependent Property in the Referential Constraint on the Orders-Customer association (double-click the association in the EF designer).

0

精彩评论

暂无评论...
验证码 换一张
取 消