c# - Generics: Type cannot be implicitly converted -


I have the following categories:

  Public Interface IWaybillDocument {long DocumentId {find; Set; } Receive a long billing document ID { Set; } String shiptonname {get; Set; } Byte address type {get; Set; } String City {Received; Set; } String country {get; Set; } Get String Postcode { Set; } String Steregeian {get; Set; } String Street 1 {Get; Set; } String Street 2 {Received; Set; } String suburbs {get; Set; } Zero merge addressing (address address); }} Public Class Vibrator DocumentList: ERPL ListBase & lt; IWaybillDocument & gt; {Public WaybillDocumentList (): Base () {}} Public Partial Class WaybillDocument: IWaybillDocument, Inonrepudiable {Public Zero MergeAddressing (address addresses) {address.Street1 = this.Street1; Address.Street2 = this.Street2; Address. Subtitles = this Suburb; Ct = ct.City; Address.ZipCode = this.PostCode; Address.StateRegion = this.StateRegion; Address. Address.AddressKind = (AddressKind) this.AddressType; }}  

They all compile well but when trying to apply this extension method:

  public static EntitySet & lt ; T & gt; ToEntitySetFromInterface & LT; T, u & gt; (The IList & lt; u & gt; Source) where T: Square, U {var ess = New EntitySet & lt; T & gt; (); IEnumerator & lt; U & gt; Ie = source.GetEnumerator (); While (i.e. MeNext ()) {es.Add ((t) ie.Current); } Return SAS; }  

Like this:

  Enter public Zero InsertWaybills (WaybillDocumentList waybills) {try {; This.Context.WaybillDocuments.InsertAllOnSubmit (waybills.ToEntitySetFromInterface & lt; WaybillDocument, IWaybillDocument & gt; ()); This.Context.SubmitChanges (); } Hold (exception before) {new deluxe ("zero inserts vs. WebList) failed:" + pre., Message, east); }}  

I get a compilation error

Type 'WaybillDocument' should not be used as a type parameter 'T' in the normal type or method Can 'LinqExtensions .toEntitySetFromInterface (System.Collections.Generic.IList)' There is an underlying reference conversion from 'WaybillDocument' to 'IWaybillDocument'

  waybills.ToEntitySetFromInterface & LT; WaybillDocument, IWaybillDocument & gt; ()  

Underlined why this happens when it explicitly inherits the interface?

Update: ERPPlustBase (Details deleted)

  Public class ERPListBase & lt; T & gt; : List & lt; T & gt; {Public ERPListBase (): Base () {}}  

I have pasted you With the new project code and with some modifications such as ERPListBase -> list and compile it, then my guess is that you have two interfaces iWaybillDocument and you are referring to the wrong one of them.


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -