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

Services Web Discussion :

[Ado.net Data Service] l'expand ne semble pas fonctionner


Sujet :

Services Web

  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 : 40
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Points : 1 257
    Points
    1 257
    Par défaut [Ado.net Data Service] l'expand ne semble pas fonctionner
    Bonjour,

    Je suis en train de tester "Astoria" (Ado.net data service) avec une appli silverlight.

    J'ai donc créer ma base de données (avec une table Category et une Table SubCategory qui possède une Category via FK).

    J'ai généré mon edmx : mon entité SubCategory a donc une propriété Category.

    J'ai créé mon service astoria en mettant le type generic sur les entités EF précédante et en configurant le service dans un mode "full trust".

    Je genere le proxy coté client et je peux m'amuser avec ce framework.

    Si je remarque certains cas peu pratiques en écriture comme la liaison des entités à l'aide du "AddLink" j'ai de réels problèmes avec l' "expand" (équivalant du include en EF)

    en effet lorsque je fais un

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    proxy.CreateQuery<SubCategory>("SubCategory").Expand("Category")
    Quoi qu'il arrive ma propriété Category de mes objets SubCategory récupéré contient "null" ...

    Est ce que j'ai raté quelque chose ?

    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 : 40
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Points : 1 257
    Points
    1 257
    Par défaut
    En fait ce qui m'étonne le plus c'est que cela fonctionne bien dans un sens :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
                var getCats = ctx.Objects<service.Category>().Expand("SubCategory").Where(c => c.Name != null)
                    as DataServiceQuery<service.Category>;
     
                getCats.BeginExecute(r => liCategories.ItemsSource = getCats.EndExecute(r), null);
    Qui ramène bien tout mais pas cela :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
                var getCats = ctx.Objects<service.SubCategory>().Expand("Category").Where(c => c.Name != null)
                    as DataServiceQuery<service.SubCategory>;
     
                getCats.BeginExecute(r =>
                {
                    cbxSubCategorys.ItemsSource = getCats.EndExecute(r);
                }, null);
    Incroyable

  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 : 40
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Points : 1 257
    Points
    1 257
    Par défaut
    Bon je continue ma recherche.

    J'ai regardé l'url généré et je l'ai testé directement :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    http://localhost:55220/TodoDataService.svc/SubCategory()?$filter=Name ne null&$expand=Category
    Je vois dans le xml resultant que les objets Category sont bien present contrairement a cette url :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    http://localhost:55220/TodoDataService.svc/SubCategory()?$filter=Name ne null&
    Il y aurai donc un problème dans le remplissage de mes objets ... Je suis donc aller voir mes objet mais je n'y vois pas grand chose de spécial, les voici (pour ceux que ça inspire) :

    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
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    [global::System.Data.Services.Common.DataServiceKeyAttribute("Id")]
        public partial class SubCategory
        {
            /// <summary>
            /// Create a new SubCategory object.
            /// </summary>
            /// <param name="ID">Initial value of Id.</param>
            /// <param name="name">Initial value of Name.</param>
            public static SubCategory CreateSubCategory(global::System.Guid ID, string name)
            {
                SubCategory subCategory = new SubCategory();
                subCategory.Id = ID;
                subCategory.Name = name;
                return subCategory;
            }
            /// <summary>
            /// There are no comments for Property Id in the schema.
            /// </summary>
            public global::System.Guid Id
            {
                get
                {
                    return this._Id;
                }
                set
                {
                    this.OnIdChanging(value);
                    this._Id = value;
                    this.OnIdChanged();
                }
            }
            private global::System.Guid _Id;
            partial void OnIdChanging(global::System.Guid value);
            partial void OnIdChanged();
            /// <summary>
            /// There are no comments for Property Name in the schema.
            /// </summary>
            public string Name
            {
                get
                {
                    return this._Name;
                }
                set
                {
                    this.OnNameChanging(value);
                    this._Name = value;
                    this.OnNameChanged();
                }
            }
            private string _Name;
            partial void OnNameChanging(string value);
            partial void OnNameChanged();
            /// <summary>
            /// There are no comments for Category in the schema.
            /// </summary>
            public Category Category
            {
                get
                {
                    return this._Category;
                }
                set
                {
                    this._Category = value;
                }
            }
            private Category _Category;
            /// <summary>
            /// There are no comments for Todo in the schema.
            /// </summary>
            public global::System.Collections.ObjectModel.Collection<Todo> Todo
            {
                get
                {
                    return this._Todo;
                }
                set
                {
                    if ((value != null))
                    {
                        this._Todo = value;
                    }
                }
            }
            private global::System.Collections.ObjectModel.Collection<Todo> _Todo = new global::System.Collections.ObjectModel.Collection<Todo>();
        }
     
    [global::System.Data.Services.Common.DataServiceKeyAttribute("Id")]
        public partial class Category
        {
            /// <summary>
            /// Create a new Category object.
            /// </summary>
            /// <param name="ID">Initial value of Id.</param>
            /// <param name="name">Initial value of Name.</param>
            public static Category CreateCategory(global::System.Guid ID, string name)
            {
                Category category = new Category();
                category.Id = ID;
                category.Name = name;
                return category;
            }
            /// <summary>
            /// There are no comments for Property Id in the schema.
            /// </summary>
            public global::System.Guid Id
            {
                get
                {
                    return this._Id;
                }
                set
                {
                    this.OnIdChanging(value);
                    this._Id = value;
                    this.OnIdChanged();
                }
            }
            private global::System.Guid _Id;
            partial void OnIdChanging(global::System.Guid value);
            partial void OnIdChanged();
            /// <summary>
            /// There are no comments for Property Name in the schema.
            /// </summary>
            public string Name
            {
                get
                {
                    return this._Name;
                }
                set
                {
                    this.OnNameChanging(value);
                    this._Name = value;
                    this.OnNameChanged();
                }
            }
            private string _Name;
            partial void OnNameChanging(string value);
            partial void OnNameChanged();
            /// <summary>
            /// There are no comments for SubCategory in the schema.
            /// </summary>
            public global::System.Collections.ObjectModel.Collection<SubCategory> SubCategory
            {
                get
                {
                    return this._SubCategory;
                }
                set
                {
                    if ((value != null))
                    {
                        this._SubCategory = value;
                    }
                }
            }
            private global::System.Collections.ObjectModel.Collection<SubCategory> _SubCategory = new global::System.Collections.ObjectModel.Collection<SubCategory>();
        }

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

    Informations forums :
    Inscription : Mars 2004
    Messages : 1 559
    Points : 1 257
    Points
    1 257
    Par défaut
    Bon j'ai réussi a faire marcher tout ça en utilisant un proxy avec un scope plus ... "limité" !

    sauf que je perd l'optimisation que le context était sensé faire sur du multi requêtes ...

    Bon mon premier avis sur ce framework : sympa sur le papier mais assez imature dans les fait le loading et l'association des entités est vraiment lourd et quelques comportement étonnant... faudra que je creuse un peu

    Bon je ferme le monologue

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

Discussions similaires

  1. Réponses: 1
    Dernier message: 01/10/2009, 09h54
  2. [EF] Problème avec ASTORIA (ADO.NET Data services)
    Par Smallde dans le forum Accès aux données
    Réponses: 0
    Dernier message: 11/03/2009, 09h56
  3. Réponses: 2
    Dernier message: 20/11/2008, 22h34
  4. Probleme avec ado.net data services .
    Par superkiller dans le forum Windows Communication Foundation
    Réponses: 0
    Dernier message: 27/10/2008, 14h00

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