Prev | Current Page 221 | Next

Satheesh, N Kumar

"LINQ Quickly"

Field("CategoryID") == 1
select new
{
itemID = item.Field("IItemID"),
category = cats.Field("CategoryName"),
itmName = item.Field("Name")
LINQ over DataSet
[ 148 ]
};
foreach (var itmcat in itemCategories)
{
Console.WriteLine("ItemID:" + itmcat.itemID + " Category:" +
itmcat.category + " Name:" + itmcat.itmName);
}
If it is a typed DataSet, the previous query is written as follows:
var rowItemCategories = from cats in categories
join item in items
on cats.CategoryID equals
item.CategoryID
where cats.CategoryID == 1
select new
{
itemID = item.IItemID,
category = cats.CategoryName,
itmName = item.Name
};
foreach (var itmcat in rowItemCategories)
{
Console.WriteLine("ItemID:" + itmcat.itemID + " Category:"
+ itmcat.category + " Name:" + itmcat.itmName);
}
With this query, we can avoid referencing the column using a field and casting it to
the type of the database column. We can directly refer to a column in the table using
the database column name.
DataSet Query Operators
LINQ to DataSet adds several DataSet-specific operators to the standard query
operators available in System.


Pages:
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
stolarka aluminiowa częstochowa Potopek uchwyt lcd wyciągarki hotele londyn