.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

Using Linq to Objects within an ASP.Net application

Posted By: nikolaosk     Posted Date: September 21, 2010    Points: 0   Category :ASP.Net
I am thinking to continue the LINQ series of posts but I want to give a clear example on Linq to Objects . In all my classes people seem to have the following answer to this question, " What kind of data can we query with LINQ? " Most people say " Well, we can query an SQL server database " . I am not very pleased when people forget the other flavors. LINQ to Objects allow us to write "queries" over collections of objects.This is the first and most basic flavor of LINQ. LINQ to Objects enables you...(read more)

View Complete Post

More Related Resource Links

How to create 3 tier application using LINQ

As you know that in 3 tier architecture there are three layers

User interface layer. (Is our Form in Windows application and .aspx page in Web application)
Data Access layer. (Which provides interface between Business logic layer and Database)
Business Logic layer.(Which stores your application logic)

examples of recomended linq to sql n-tier application

Hi Are there any best practise examples of a c# n-tier solution. Perhaps showing the dal, business layers caching etc, with example files, projects and code? I've read lots of theory, but I'd like to actually see an example of something. Thanks Stu

Analysis of number of objects in a SharePoint application

How can I quickly find the following with no custom coding? Number of documents in a SharePoint Applications? Number of lists & libraries?

ViewState and LINQ to SQL objects


I'm getting the following error: "Type 'System.Data.Linq.ChangeTracker+StandardChangeTracker' in Assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."

Basically, I have a LINQ entity class built from LINQ to SQL called City, which implements INotifyPropertyChanging and INotifyPropertyChanged that I'm trying to store in ViewStateWhen I remove these interfaces from the class, the error goes away.  When left on, the error is there.

I know that these interfaces are what enable the DataContext object's to track changes and persist those changes to the database using the dc.SubmitChanges() method.  Is there anything that I need to do to be able to enable storing a LINQ to SQL object in ViewState?  I thought I read that this was possible, and that Asp.net allowed persisting changes like that across post-backs.


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...

NullReferenceException was unhandled by usercode in mvc application using linq to sql


Hi friends

I am getting an exception like"NullReferenceException was unhandled by usercode-Object reference not set to an instance of an object." in (IEnumerable)Viewdata.Model.

 <% foreach (EmployeeMaster m in (IEnumerable)ViewData.Model)
               { %>

I am getting exception in the below code (view page)

<% foreach (EmployeeMaster m in (IEnumerable)ViewData.Model)

      { %>

Kindly help me in this issue...

Transferring objects between a Web Service and Silverlight Phone Application


I am fairly new to the Silverlight and Web Services, unfortunately I have come across an issue that seems seems to make each one more complicated for me. What I am trying to do is use a Web Service to connect a Silverlight Phone Application with an SQL Server 2008 database. Connecting and getting data from the database is easy, but my issue lies with transferring it back to the Phone Application using the web service.

Currently there are 2 projects - one is the actual Phone Application, and the other is a web application with the ASMX.

In the Phone Application project is a Customer class (basic attributes - id, name, phone number etc), which I want to fill with data from SQL Server using the Web Service. Visual Studio is not letting me directly use the Customer class from the Silverlight Project in the Web Service, same if I were to create the class in the Web Application and use it in the Silverlight Application.

What I planned on doing was iterating through the data set in the web service and create an XmlDocument, which has been created successfully. The InnerText of this document is:

"<?xml version=\"1.0\" encoding=\"utf-8\"?>




<Name>SMITH, John</Name>




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

Microsoft's Collaborative Application Markup Language (CAML) Loop

discovered an interesting error recently while working with Microsoft's Collaborative Application Markup Language (CAML) that, surprisingly, had received no ink. Partly what surprises me about this is that the error may require you to rewrite large sections of your code if you haven't previously considered this SharePoint limitation. I'll start with some context, but first of all the error is:

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.

Linq to Sql CompiledQuery container

Ok now let's go. Here is just a little trick but with some interesting patterns that could be useful in some other contexts not connected to Linq to Sql.

When using Linq expressions, like with Linq to Sql, translating the expression into something else (sql for example) is taking time and resources. Sometimes it's negligible, sometimes not...
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