New Posts New Posts RSS Feed: Projection into Known Type
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Projection into Known Type

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: Projection into Known Type
    Posted: 05-Dec-2012 at 10:52am
I created a test query against NorthwindIB. If I run the query without using a known type, then it returns the expected data. But when I add the EmployeeSlice, then it returns the correct number of entities, but there is no data in the entities. I am currently using version 6.1.5. The EmployeeSlice is defined on the Server project, and linked to the SL project.



var query = em.Employees.Select(emp => new EmployeeSlice()
            {
               EmployeeID = emp.EmployeeID,
               FirstName = emp.FirstName,
               LastName = emp.LastName
            }
               ).ExecuteAsync((results) =>
               {
                    foreach (var employee in results.Results)
                    {
                        //Return returns 9 slices, but all data is empty.
                    }
               });

[DataContract]
    public class EmployeeSlice : IKnownType
    {
        public int EmployeeID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 05-Dec-2012 at 11:07am
Hi Greg,
 
Sinc you've added a DataContract attribute to the EmployeeSlice you also need to decorate members with the DataMember attribute.  Alternately, you can remove the DataContract attribute on the class, and all public properties will then serialize.
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2012 at 11:06am
Great, thanks.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down