开发者

Object Model Contracts

开发者 https://www.devze.com 2022-12-24 08:00 出处:网络
I\'m trying to create a data model for WCF based off of interfaces from my core object model, but I\'m having trouble with some of the associations

I'm trying to create a data model for WCF based off of interfaces from my core object model, but I'm having trouble with some of the associations

Currently I have this in my core data model

public class A : IA {
       public string name { /* ... */ }
       public EntitySet<B> children { /* ... */ }
}
public class B : IB {
       public string name { /* ... */ }
}

However when I define the interface IA I get compiler errors saying A doesn't implement all of IA. Here is the interface

public interface IA<BType> where BType: IB  {
   string name {get; set;}
 开发者_StackOverflow社区  IEnumerable<Btype> children {get;}
}

Why can't an instance of A be passed as an IA reference, given these class and interface definitions?


Compilation error because public EntitySet<B> children is not implementation of IEnumerable<Btype> children {get;} (.net <4.0 version does not support covariance\contravariance)

0

精彩评论

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