Aug 26 2009

Anonymous Types in Silverlight 2.0

Category: silverlight 2.0Bil@l @ 17:03

If you are querying a collection in Silverlight 2.0 using LINQ and you want to extract a subset of the properties on the queries collection objects, you cannot make use of Anonymous Types in LINQ. For instance the following query won't return any value:

    public class Employee
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

            List<Employee> employees = new List<Employee>();
            employees.Add(new Employee { FirstName = "Bilal", LastName = "Haidar" });
            employees.Add(new Employee { FirstName = "Bill", LastName = "Gates" });

            var results = from emp in employees
                          select new { FirstName = emp.FirstName };

results will be empty as Anonymous Types are not supported.

A solution can be done by disecting your domain objects in this case a very simple object (Employee) into smaller structs

    public struct SubEmployee
    {
        public string FirstName { get; set; }
    }

And the query could be as follows:

            IEnumerable<SubEmployee> results = from emp in employees
                          select new SubEmployee{ FirstName = emp.FirstName };

 

You can have as many structs as you want to ease your work.

Hope this tip helps!
Regards

Tags:

Aug 19 2009

The remote server returned an error: NotFound. -- Silverlight Exception

Category:Bil@l @ 16:01

While working on a Silverlight application and you face such exception: "The remote server returned an error: NotFound."

You should check this blog post:

Silverlight and WCF Essentials - Fiddler

 

Regards

 

Tags:

Aug 18 2009

Columns &amp; Rows - Silverlight Series on DataGrid - ASPNETPRO

Category:Bil@l @ 06:20

Now you can view most of the series of my articles on Silverlight DataGrid hosted by ASPNETPRO magazine:

Columns & Rows Part I: Silverlight 2.0 DataGrid Properties

Columns & Rows Part II: Silverlight 2.0 DataGrid Columns

Columns & Rows Part III: Working with DataGrid Master/Detail

Columns & Rows Part IV: Silverlight 2.0 DataGrid CRUD Operations

 

Hope you enjoy reading them.

Regards

Tags:

Aug 16 2009

RadControls Silverlight 3 Official with Q2 2009 SP1

Category: silverlight 3.0Bil@l @ 19:28

Telerik RadControls for Silverlight3 are here with the latest 2009 Q2 SP1 release!

Read more here:

RadControls Silverlight 3 Official with Q2 2009 SP1

 

Enjoy Silverlightening......

Tags: