Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LINQ query requesting that the object type declared rather than bing implicit

Posted on 2012-03-12
4
Medium Priority
?
778 Views
Last Modified: 2012-03-12
oEngine = New FileHelperEngine(GetType(CUPSMapping))
 Dim oMappings As CUPSMapping() = CType(oEngine.ReadFile(Filename), CUPSMapping())

Dim query = From oMap In oMappings
                        Select oMap


The error message when mouse over 'query' is this.  Linq has been imported

Variable declaration without an 'AS' clause; type of object assumed
0
Comment
Question by:Alyanto
[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
4 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 2000 total points
ID: 37710446
Either put "Option Infer On" at the top of the code file, or change it at the project level in the project properties compile tab.

Option Infer Statement
http://msdn.microsoft.com/en-us/library/bb384665.aspx
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37710456
Dim query = From oMap In oMappings
                        Select oMap

should be:

dim query as List(of CupsMapping) = From  oMap In oMappings
                        Select oMap

'It's complaining that query type is not defined.  You need to specify query as something.



Is query correct or is it truly the result?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37710521
I think instead that the problem is on the range variable:

Dim query = From oMap As CUPSMapping In oMappings
                        Select oMap

Open in new window


If it were as ged325 describes, then what would you do when you were SELECTing an anonymous type!!!

On a side note, what is the purpose of the LINQ query anyway? You are merely selecting with nothing else. The net effect is you get back an IEnumerable(Of CUPSMapping). An array should already be enumerable. Are you passing the result of this query to some other function which has an explicit IEnumerable(Of CUPSMapping) signature?
0
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 37710562
Bloody marvelous, thank you
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

705 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