Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Create a custom class in a linq query in silverlight

$
0
0

How can I run a LINQ query in a silverlight application  that will generate a list of a local class?

For example in server side code I have something like;

        public static List<TeamDescription> ListLeaveTeams2(IOrganizationService service, Guid userid)
        {
            List<TeamDescription> qtu = new List<TeamDescription>();

            // context for query
            MyContext ctx = new MyContext(service);

            // a query to list all teams
            var queryTeams = from tm in ctx.TeamMembershipSet
                             join u in ctx.SystemUserSet on tm.SystemUserId.Value equals u.SystemUserId.Value
                             join t in ctx.TeamSet on tm.TeamId.Value equals t.Id
                             where (tm.SystemUserId == userid)
                             where t.AdministratorId.Id != userid
                             select new TeamDescription(tm.TeamId, t.Name, u.FullName, tm.SystemUserId.Value, t.AdministratorId.Id);

            // Some loop through that data - must be a better way to do this!
            foreach (TeamDescription team in queryTeams)
            {
                qtu.Add(team);
            }

            return qtu;
        }

And that works, qtu is a list of the local class TeamDescription. I am trying to do something similar in a silverlight application. e.g.;

binding = new DataServiceCollection<CaseView>();
binding.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(Cases_LoadCompleted);

var query = from c in config.context.IncidentSet
            select new CaseView() { CustomerName = c.CustomerId.Name, Description = c.Description, CaseNumber = c.TicketNumber, ServiceLevel = c.PriorityCode.ToString(), LoggedTime = c.CreatedOn.Value, ResolveBy = c.qubic_servicemoule_fixdeadline.Value, Status = c.qubic_case_Status.ToString(), Queue = c.qubic_servicemodule_Queue.Name, Owner = c.OwningUser.Name };
binding.LoadAsync(query);

and I get all kind of errors, Unable to bind to c.CustomerID.Name, property names must be identical etc.

How can I create a list of my local custom class in silverlight and linq

Ta


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>