Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using a DomainService with CRUD statements (Silverlight)

Posted on 2010-08-15
3
Medium Priority
?
673 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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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…

971 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