Solved

Using a DomainService with CRUD statements (Silverlight)

Posted on 2010-08-15
3
669 Views
Last Modified: 2013-11-12
In my DomainService which is accessing a ADO.NET (.edmx) file I have the following function which returns ALL columns

Public Function GetOpenPOs() As IQueryable(Of PartNumberHistory)
        Return Me.ObjectContext.PartNumberHistories.Where(Function(e) e.OpenClosed = "OPEN PO" And e.NumOfQty = 1 And e.LineItem = 1).OrderBy(Function(e) e.PO)
    End Function

This works great and when I edit the grid and click "Submit Changes" button - everything is saved - works like a charm

Problem is I *want* to only return (and be able to edit) a few of the columns....

I try this function

Public Function GetOpenPOs() As IQueryable(Of PartNumberHistory)
        Return Me.ObjectContext.PartNumberHistories.Where(Function(e) e.OpenClosed = "OPEN PO" And e.NumOfQty = 1 And e.LineItem = 1).OrderBy(Function(e) e.PO).Select(Function(e) e.PO)
    End Function

But get the error:
Error      1      'System.Linq.IQueryable(Of String)' cannot be converted to 'System.Linq.IQueryable(Of BusinessApplication9.PartNumberHistory)' because 'String' is not derived from 'BusinessApplication9.PartNumberHistory', as required for the 'Out' generic parameter 'T' in 'Interface IQueryable(Of Out T)'.

How can I make this work?  The client seeing all of the columns is just overkill

Thanks!
0
Comment
Question by:ProdigyOne2k
  • 2
3 Comments
 
LVL 21

Expert Comment

by:tovvenki
ID: 33444132
Hi,
See if this helps you
http://forums.silverlight.net/forums/p/171512/387088.aspx

Thanks and regards,
Venki
0
 
LVL 7

Expert Comment

by:vbigham
ID: 33532970
The select statement on the end is changing your return type.  Try removing that, and you should get a list of the entities back.

like this:

Return Me.ObjectContext.PartNumberHistories.Where(Function(e) e.OpenClosed = "OPEN PO" And e.NumOfQty = 1 And e.LineItem = 1).OrderBy(Function(e) e.PO)
0
 
LVL 7

Accepted Solution

by:
vbigham earned 500 total points
ID: 33533000
I would just not show any columns that don't apply, but I don't think that these domain services will allow you to return an IQueryable(Of String).  

If I remember right it tells you that is not a valid entity type.  You could try changing  IQueryable(Of PartNumberHistory) to IQueryable(Of String) to see what I mean.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question