IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Communication Foundation .NET Discussion :

POCO WCF IsReference et BaseClass


Sujet :

Windows Communication Foundation .NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé Avatar de anthyme
    Homme Profil pro
    Inscrit en
    Mars 2004
    Messages
    1 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Par défaut POCO WCF IsReference et BaseClass
    Bonjour,

    J'éprouve des difficultés à taguer mes entités avec des [DataContract(IsReference=true)]

    Voici mon model objet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    [DataContract(IsReference=true)]
    public abstract class Entity<idT> : IEntity<idT>
    {
        public idT Id { get; set; }
    }
     
    [DataContract(IsReference=true)]
    public class Todo : Entity<int>
    {
        public virtual string Title { get; set; }
        public virtual string Description { get; set; }
        public int Version { get; set; }
        public virtual DateTime CreationDate { get; set; }
        public virtual DateTime UpdateDate { get; set; }
        public virtual Category Category { get; set; }
    }
     
    [DataContract(IsReference=true)]
    public class Category : Entity<int>
    {
        public virtual string Name { get; set; }
        public virtual IList<Todo> Todos { get; set; }
    }
    - Quand je tag Category et Todo de [DataContract(IsReference=true)] j'ai une erreur disant que la classe de base doit aussi avoir un Tag DataContract
    - Quand je rajoute le tag [DataContract] sur ma classe Entity<T> cela ne marche toujours pas car il faut avoir IsReference a true sur toute la chaine
    - Quand je rajoute le tag [DataContract(IsReference=true)] sur ma classe Entity<T> j'ai une erreur lors de la génération de mon Proxy de service (application silverlight 4) :


    Warning 4 Custom tool warning: An item with the same key has already been added. D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Warning 5 Custom tool warning: Cannot import wsdl:portType
    Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
    Error: Referenced type 'Arch.Model.Entity`1, Arch.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' with data contract name 'EntityOfint' in namespace 'http://schemas.datacontract.org/2004/07/Arch.Model' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types.
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ITodoService'] D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Warning 6 Custom tool warning: Cannot import wsdl:binding
    Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
    XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ITodoService']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ITodoService'] D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Warning 7 Custom tool warning: Cannot import wsdl:port
    Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
    XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ITodoService']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='TodoService']/wsdl:port[@name='BasicHttpBinding_ITodoService'] D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Warning 8 Custom tool warning: No endpoints compatible with Silverlight 4 were found. The generated client class will not be usable unless endpoint information is provided via the constructor. D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Warning 9 Custom tool warning: Exception has been thrown by the target of an invocation. D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Error 10 Custom tool error: Failed to generate code for the service reference 'TodoService'. Please check other error and warning messages for details. D:\Users\Anthyme\Documents\Visual Studio 2010\Projects\ArchSharp\Arch.Poc.Silverlight\Service References\TodoService\Reference.svcmap 1 1 Arch.Poc.Silverlight
    Bon j'avoue ne pas comprendre ... Si quelqu'un a une idée je suis ouvert !

    Merci

  2. #2
    Membre éprouvé Avatar de anthyme
    Homme Profil pro
    Inscrit en
    Mars 2004
    Messages
    1 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Par défaut
    Bon je vais essayer ce soir avec une classe EntityInt au lieu de Entity<int>, si ça marche j'ai un peu les boules car ça casse mon modele ...

  3. #3
    Membre éprouvé Avatar de anthyme
    Homme Profil pro
    Inscrit en
    Mars 2004
    Messages
    1 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Par défaut
    Bon j'ai trouvé la solution !

    Voici comment taguer la classe générique :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    [DataContract(Name = "EntityOfType{0}", IsReference = true)]
    public abstract class Entity<idT> : IEntity<idT>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Architecture] WCF Services
    Par leMarseillais dans le forum Windows Communication Foundation
    Réponses: 8
    Dernier message: 08/03/2007, 13h08
  2. [WCF] Récupération du type de Binding
    Par NicolasR dans le forum Windows Communication Foundation
    Réponses: 1
    Dernier message: 14/02/2007, 17h36
  3. Problème de compilation des baseclass
    Par lzw1015bean dans le forum DirectX
    Réponses: 5
    Dernier message: 31/05/2006, 20h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo