Solved

Linq to sql convery results to typed dataset

Posted on 2010-09-23
5
414 Views
Last Modified: 2013-11-11
After I execute the linq query and get the results, is it possible to convert the result set to a typed dataset?
for eg. the code i have is:
   Dim ItemInfo = _
    From Items In dataContext.Items _
    Where Items.ItemNmbr = txtItem.Text.Trim _
    Select Items

I want to convert iteminfo to something like
dim dtitem as new dsItem.dtItemDatatable
then convert iteminfo to type dtItem
0
Comment
Question by:TrialUser
5 Comments
 
LVL 3

Accepted Solution

by:
Exempo earned 125 total points
ID: 33746474
You can use the CopyToDataTable function.
Here is an article that describes it.
http://msdn.microsoft.com/en-us/library/bb396189.aspx
0
 
LVL 21

Assisted Solution

by:naspinski
naspinski earned 125 total points
ID: 33749235
you could directly cast the items into the type you want them to be, then the query output would be IEnumerable<whateverTypeYouWant>:
Dim ItemInfo = _
    From Items In dataContext.Items _
    Where Items.ItemNmbr = txtItem.Text.Trim _
    Select new SomeClass() { name = Items.name }
//not sure how that works in VB...

Open in new window

0
 
LVL 5

Assisted Solution

by:vivekpv10
vivekpv10 earned 250 total points
ID: 33750917
0
 
LVL 5

Assisted Solution

by:vivekpv10
vivekpv10 earned 250 total points
ID: 33778750
0
 

Author Closing Comment

by:TrialUser
ID: 33795013
thanks
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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