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