Précédent   Forum du club des développeurs et IT Pro > Dotnet > Développement Web avec .NET > Windows Azure
Windows Azure Forum d'entraide sur la plateforme de Cloud Computing Windows Azure
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 17/11/2012, 18h22   #1
Leskate
Invité régulier
 
Homme Bastien
Développeur .NET
Inscription : mars 2011
Messages : 28
Détails du profil
Informations personnelles :
Nom : Homme Bastien
Localisation : France

Informations professionnelles :
Activité : Développeur .NET
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : mars 2011
Messages : 28
Points : 8
Points : 8
Par défaut Insertion en base via un service Azure Mobile

Bonjour à tous,

Je suis en train de tester Windows Azure, et j'aimerais créer un utilisateur, avec un droit associé.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Utilisateur
{
     public int Id { get; set; }
 
     [DataMember(Name = "login")]
     public string Login { get; set; }
 
     [DataMember(Name = "droit")]
     public Droit Droits { get; set; }
 
     [DataMember(Name = "password")]
     public string Password { get; set; }
}
 
public class Droit
{
    public int Id { get; set; }
 
    [DataMember(Name = "label")]
    public string Label { get; set; }
 
    [DataMember(Name = "image")]
    public string Image { get; set; }
}
Du côté de Azure, j'ai deux tables créées : Utilisateur et Droit.

La création d'un droit fonctionne parfaitement :
Code :
1
2
3
4
5
6
7
8
9
10
11
IMobileServiceTable<Droit> droitTable = App.MobileService.GetTable<Droit>();
var items = await droitTable.Where(i => i.Label == label).ToListAsync();
if (items == null || !items.Any())
{
    var droit = new Droit
    {
        Label = label,
        Image = string.Empty
    };
await droitTable.InsertAsync(droit);
}
Cependant, lorsque je souhaite ajouter un utilisateur avec une association à un droit donné (de la façon suivante) :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
IMobileServiceTable<Utilisateur> tableUser = App.MobileService.GetTable<Utilisateur>();
var users = await tableUser.Where(i => i.Login == "Bastien").ToListAsync();
if (users == null || !users.Any())
{
    var droit = await App.MobileService.GetTable<Droit>().Where(i => i.Label == "Administrateur").Take(1).ToListAsync();
    var user = new Utilisateur
    {
        Login = "Nom_utilisateur",
        Password = "Pass_utilisateur",
        Droits = droit.FirstOrDefault()
    };
    await tableUser.InsertAsync(user);
}
J'ai une erreur :
Citation:
Cannot serialize member 'droit' of type 'portable_pome.Data.Droit' declared on type 'Utilisateur'.
Que cela signifit-il ? Qu'ai-je oublié pour faire fonctionner la jointure ?

Merci d'avance !
Leskate est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/11/2012, 00h14   #2
GuruuMeditation
Expert Confirmé
 
Avatar de GuruuMeditation
 
Homme Olivier Matis
.Net Architect
Inscription : octobre 2010
Messages : 1 352
Détails du profil
Informations personnelles :
Nom : Homme Olivier Matis
Âge : 38
Localisation : Belgique

Informations professionnelles :
Activité : .Net Architect
Secteur : Conseil

Informations forums :
Inscription : octobre 2010
Messages : 1 352
Points : 2 869
Points : 2 869
Envoyer un message via MSN à GuruuMeditation
Je ne suis pas spécialiste Azure, mais je crois que les Mobile Services sont encore un peu limite question fonctionnalités. Il semble qu'il n'accepte que des types de base (string,bool,datetime, type numerique,...)

voir :

http://blogs.msdn.com/b/carlosfiguei...ple-types.aspx

http://blogs.msdn.com/b/carlosfiguei...tionships.aspx
__________________
Microsoft MVP : Visual C#

MCPD - Windows Phone Developer
MCPD - Windows Developer 4

http://www.guruumeditation.net

“If debugging is the process of removing bugs, then programming must be the process of putting them in.”
(Edsger W. Dijkstra)
GuruuMeditation est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/11/2012, 23h03   #3
Leskate
Invité régulier
 
Homme Bastien
Développeur .NET
Inscription : mars 2011
Messages : 28
Détails du profil
Informations personnelles :
Nom : Homme Bastien
Localisation : France

Informations professionnelles :
Activité : Développeur .NET
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : mars 2011
Messages : 28
Points : 8
Points : 8
Ok et bien on va adapter tout ça !
Merci de ta réponse rapide
Leskate est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 06h06.


 
 
 
 
Partenaires

Hébergement Web