Hi, Im starting to use ado.net data services in a little silverlight application that Im putting together. Currently I'm using it in the most simplistic was possible:
var teams = (from t in ents.tblTeams
select t) as DataServiceQuery<tblTeams>;
teams.BeginExecute(
(ar) => this.cmTeams.ItemsSource = teams.EndExecute(ar).ToList(), null);
This is all well and good but I would really like to be able to grab only a select set of data from the database. Currently, I'm grabbing two full tables but I only need usernames and id (I may need more later).
I had thought that maybe id be able to perform this shaping within the silverlight by selecting only a subset of data:
var teams = (from t in ents.tblTeams.Expand("tblUsers")
select new TeamDTO
{
TeamID = t.TeamID,
TeamName = t.TeamName,
Members = (from u in t.tblUsers
select new UserDTO { UserID = u.UserID, UserName = u.UserName }).ToList()
}) as DataServiceQuery<TeamDTO>;
teams.BeginExecute(
(ar) => this.cmTeams.ItemsSource = teams.EndExecute(ar).ToList(), null);
However, this code doesn't seem to work (Object reference not set to an instance of an object - probably my bad code).
Basically, is there anyway to return only sets of data or is that something that I have to build in at the server level, with the data model somehow?
Thanks,