Solved

Using a DomainService with CRUD statements (Silverlight)

Posted on 2010-08-15
3
670 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to make search between pages 17 60
Get sourcecode path 14 64
Asp.Net Session Question 2 49
Consume a webservice via VB in Visual Studio 2015 3 46
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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