Created
October 1, 2012 04:58
-
-
Save amitapl/3809541 to your computer and use it in GitHub Desktop.
Windows Azure Mobile Services Joined Table View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Data | |
{ | |
public MobileServiceClient MobileService = new MobileServiceClient("", ""); | |
private IMobileServiceTable<UserGroupExtended> userGroupExtendedTable; | |
public async Task<IList<UserGroupExtended>> GetGroupUsers(string groupId) | |
{ | |
return await this.MobileService.GetTable<UserGroupExtended>(new { groupId = groupId }).ToListAsync(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DataTable(Name = "userGroup")] | |
public class UserGroup | |
{ | |
[DataMember(Name = "id")] | |
public int Id { get; set; } | |
[DataMember(Name = "userId")] | |
public string UserId { get; set; } | |
[DataMember(Name = "groupId")] | |
public string GroupId { get; set; } | |
[DataMember(Name = "friendlyName")] | |
public string FriendlyName { get; set; } | |
} | |
[DataTable(Name = "userGroupsExtended")] | |
public class UserGroupExtended : UserGroup | |
{ | |
[DataMember(Name = "userName")] | |
public string UserName { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function read(query, user, request) { | |
var sql = | |
"select [user].name as userName, userGroup.groupId, userGroup.userId, userGroup.friendlyName, userGroup.id " + | |
"from userGroup " + | |
"inner join [user] on [user].userId = userGroup.userId " + | |
"where userGroup.groupId in " + | |
"(select groupId from userGroup where userId = ?) and userGroup.groupId = ?;"; | |
mssql.query(sql, [user.userId, request.parameters.groupId], { | |
success: function(results) { | |
request.respond(statusCodes.OK, results); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment