Solved

Using a DomainService with CRUD statements (Silverlight)

Posted on 2010-08-15
3
660 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now