Link to home
Start Free TrialLog in
Avatar of ProdigyOne2k
ProdigyOne2k

asked on

Using a DomainService with CRUD statements (Silverlight)

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!
Avatar of tovvenki
tovvenki

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

Thanks and regards,
Venki
Avatar of Vaughn Bigham
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)
ASKER CERTIFIED SOLUTION
Avatar of Vaughn Bigham
Vaughn Bigham
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial