473,473 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Type Inference and LINQ

I am really jazzed about LINQ - but am struggling with some basics -
like when does it infer the datatype?

Simple example - I want to get all the tables in a typed dataset that
have "RAW" in the name. I would have thought that:

Dim qRawTables = From RawTable In ds.Tables _
Where RawTable.TableName.ToString.StartsWith("RAW")

When I hover over qRawTables it is an object. So it is not using type
inferrence right? ds.tables is returning a
System.Data.DataTableCollection - but this isn't ienumerable? I can
add .AsQueryable but then the RawTable.TableName gets a 'Late Binding'
error.

Sorry for a possibly stupid question!

Feb 11 '08 #1
3 1120
Maso,

Have you option strict On?

Dim qRawTables = From RawTable In ds.Tables _
Where DirectCast(RawTable,
DataTable).TableName.StartsWith("RAW")

Cor

Feb 12 '08 #2
On 2008-02-11 21:21:19 -0500, "Cor Ligthert[MVP]" said:
Have you option strict On?

Dim qRawTables = From RawTable In ds.Tables _
Where DirectCast(RawTable,
DataTable).TableName.StartsWith("RAW")
Cor,

Thanks (as always!)

I didn't think to try a DirectCast - it works great. I also tried
doing from RawTable as Datable and it worked... like this:

Dim qRawTables = From Rawtable as Datatable in ds.Tables _
Where Rawtable.TableName.StartsWith("RAW")

Do you know why it doesn't already know that RawTable is a datatable?
Other queries that I do are able to infer the type - is it because
ds.Tables could return other things than datatables?

Feb 12 '08 #3
Masa,

How can it know that it is a datatable and not a relation.

Cor
Feb 12 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Harold Howe | last post by:
I am running into a situation where the compiler complains that it cannot infer the type parameters of a generic method when one of the function arguments is an anonymous method. Here is a...
12
by: =?Utf-8?B?Z3V5?= | last post by:
What do people here think about VB2008 having the ability to infer type? e.g you can now say Dim i=5 which will create i as an integer Personally I do not like it as it is not consistent and may...
2
by: Chris Dunaway | last post by:
When using linq queries, is it *required* to use type inference? I was reviewing some linq samples and came across this one: public void Linq5() { string digits = { "zero", "one", "two",...
9
by: tadmill | last post by:
Is it possible to pass a generic parameter of the same class to to its constructor, where the "T" type passed in the constructor is different than the "T" type of the instanced class? ie, ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.