.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

LINQ to DataSet in .NET 4.0 - an unwelcome change

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

This worked in .NET 3.5 but it does not compile in 4.0

var allergies =  from allergy in typedDataset.allergy
where allergy != string.Empty

In 4.0, I had to cast the typed dataset to IEnumerable<> using the extension method Cast<>

var allergies = from allergy in typedDataset.allergy.Rows.Cast<TypedDataSet.allergyRow>()
  where allergy.drug != string.Empty
  select allergy;

What motivated this change?  It's much less elegant now.  The compiler should take care of the messy stuff.  Will this be fixed?

View Complete Post

More Related Resource Links

Change Sqldatasource or LINQ to SQL into a DataSet? [C#]

Hi Everyone,I've saw a couple of threads on here and on different sites around this area but none I've tried have seemed to work.What I'm struggling to achieve is, I want to take a set of results attained by either a SqlDataSource or a LINQ to SQL Method and feed them into a DataSet. Why? This is because I have downloaded an example of a repeater which has paging programmed on it, but in the example it uses the DataSet.ReadXML method to read a pre-defined set of results in an XML file. As my results are constantly changing I thought it would be a good idea for the DataSet to attain them from the previous mentioned ways.I've lost count at the number of ways I've tried it, from setting up SQLConnection method seperately and the QS set as a 'string' then passing that through etc. to simply trying Dataset Items = PartialClass.GetAll(); - Which throws back Generic<List> cannot be converted to DataSet - or something close to that.I'm working from an example and incorporating it into my own project.Below is the code I'm trying to get working:C#:protected void Page_Load(object sender, EventArgs e) { // Call the ItemsGet method to populate control, // passing in the sample data. ItemsGet(); } public void ItemsGet() { // Read sample item info from XML document into a DataSet DataSe

change to lambda in linq


Hello my friends I tried to change this code to lambda but I could not pleaaaase help me:


  var inforeport = from m in db.Products where m.UnitPrice > info select new { unit=m.UnitPrice,name= m.ProductName };


VB: Linq to SQL in Dataset

Hello,I searched for two days now and did not find a solution...I want to use Linq to SQL in my new project. However I want to have the result of a linq query stored in a Dataset instead of directly showing it on a gridview.I only found C# code that a code converter was not able to convert. Unfortunatally I do not know C# at all. Does anybody have a VB code for that?Thanks in advance!RegardsThomas

delete a row in datatable using linq to dataset

hihow can i delete a row in datatable using linq to dataset?I have a dataset in my project, need to delete some rows filtered by IDhow can i do?

Need to Change a Query String in a DataSet

I need help in pointing me in the right direction...   I have a microsoft Report (ViewDelete.rdlc) that is feeding from a DataSet(ViewDeleteDataSet.xsd). A Web Form has been created with 3 Textboxes: -Search by VehicleNr -Search By VIN -Search By TagNr The Same Web Form as Microsoft ReportViewer loading the above mentioned report.   What Needs to Happen: 1. User entered search information into one of the textboxes and clicks Search 2. Query string for the Report is updated to list only the information the user is wanting to see and reloads the report based on this query.   I have been searching for about 4 hours with no luck on how to do this.  I maybe way off on how this should work, can someone help get me going?

Change connection string of Linq to Sql entities

Hi all.I have a solution which uses Linq to SQL Data Classes to acced the db. I have a project for my domain objects in my solution, which is a class library and has the dbml file. When I set up the dmbl using the wizard, Visual Studio created an app.config file on that project with the connection string. It also creatting a settings file with the same info. I've noticed that if I change the connection string in the settings file, the app.config gets updated, which is the expected behaviour.However, I'm having a problem when I deploy my web site to the production server. I already set the app.config file's Build Action to "Content", and also set Copy to ouput directory to "Always". Nevertheless, when I install the web site and change the connection string in the app.config file, it still takes the old connection string, so obviously I get an error. I've found that it only works if I change it with in Visual Studio and then compile, but of course that's not an optimal solution, because any change in the production db server would mean I have to change my project's assembly, thus generating a new version.Any thing I'm missing? What do I have to configure so that the assembly takes the connection string form my app.config file directly after I deploy?Thanks a lot.

Create dataset from LINQ query of DataView


Is there a straightforward way to create a dataset after querying a dataview?  The query itself returns DataRowView objects, which I cannot get to work with CopyToDataTable().

The query looks like:

Dim dvQueryView As DataViewdvQueryView = (dataview object of large dataset)

detailTableQuery = From rowView As DataRowView In dvQueryView _

Order By sSortOrder _

Select rowView _

Skip nQuerySkipRow _

Take nQueryCountRows


I only want a small s

how to return linq result to dataset



        i have one class which return dataset  as a returnvalue. i write stored procedure and calling that stored procedure uding linq thsts work but after calling i want linq result must store in dataset and then i return that dataset like

 public DataSet GetData(int id)
        DataSet dsInc = new DataSet();
        AdministratorDataContext db = new AdministratorDataContext();

        var result = db.StoredProcedure1(id);

return dsInc


so i want to return dsInc i.e dataset but how i stored that result in my dataset. Reply me ASAp.

Selecting radio buttons in a gridview with dataset from Linq Query


Hi Everyone!

I've got a gridview that will allow clients to edit options they've already entered on another page.  The gridview has three radio buttons in it each with a value of 1,2,3.  The option value in the dataset is 1,2 or 3 respectively.  I would like to have the radiobutton with the corresponding value selected in the gridview so they can see what they previously chose and will then be able to edit, if they wish.

How do I do this? 

Here's my code so far:

Dim clientOption = (From c In dc.ClientOptions _
                                 Where c.clientID = userClientID _
                                 Select New With {c.clientOptionID, _
                                                  c.optionWording, _

            'Now Populate Gridview 1 with set options
            If clientOption Is Nothing Then
                Label1.Text = "There are currently no set options to edit."

                GridView1.DataSource = clientOption
                Label1.Text = "Edit set options."
            End If

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="F

creating dataset using list of objects in Linq



 I am using Linq To Sql to get List of objects with data from database. To bind data with a grid view i am creating a dataset explicitly and then adding List values to that explicitly created dataset.

Now my question is whether it is a good pratice to do what i am doing (in terms of resource utilization) or is there any better way to this...

need to change the db in LINQ to SQL.



i am using LINQ to SQL in my webservice project(using vs2008).

i want to change the database.

how can i change the database while using LINQ to SQL?

can i change the database from changing the connection string in web.config file?

the new database is identical to my old database but name is changed.

please sugggest.

Change the connectionString in linq



i have a class library and i want to use it in difrent web form application.

i created a linq data class and i drag and drop the table of my local database in it.

now i want to use this class library in my web form application with a database in server with difrent database name but with same tables and also the connectionString Name is the same.

in my class library i call myDataContax("MyConnectionStringName")

my question is when i use a connectionstring with the same connectionString Name as my Class library ConentionString Name but with difrent database name it will work or not?



Change column names in report based on another dataset


My report displays a result set from DataSet1 which contains non-descriptive column names that are shown as my column headers.

A1, A2, A3, A4, ...

I have a second Dataset that contains 'friendly' names:

A1  Jan

A2   Feb

A3  Mar


How can I map the friendly names from DataSet2 to the column names that came with DataSet1?

Thank you for any help you may be able to provide.

Playing with Linq grouping: GroupByMany?

One of its features is grouping. Many people understand grouping like it is defined in Sql. Linq is implementing grouping quite the same way. Let's discover this syntax and how to make consecutive groups easier.

LINQ : Implementing IN and NOT IN

I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

101 LINQ Samples Tutorials

101 LINQ Example with sample code snippets....This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend