Solved

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

Posted on 2012-03-12
4
774 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

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