Rich said:
Thank you again for your response. I think my real question should have
been if it is possible to use linq against a dataTable. I googled
around and saw some posts with solutions that I tried but did not work
out.
At this point, I am trying to figure out the benefit of the Entity thing
over writing plain Tsql on a sqlDataAdapter. That seems pretty easy and
straightforward compared to the entity thing, and it appears I would
have more control over my query in this scenario using Tsql. Or would
linq still offer some benefit here? Not knocking linq (I already have
it in use very nicely for some other apps), but how would I benefit from
linq/Entities in my current situation?
The end results of Linq-2-SQL or even ADO.NET Entity Framework is that
it would generate the T-SQL itself, execute it, populate an object or
List<T> of objects to present back to you. Either way you look at it
Link-2-SQL or you doing inline or T-SQL or from an sproc, T-SQL was
executed.
You load the data to a datatable only to use Linq to query it. On the
other hand, you use Linq-2-SQL to query the database table or tables and
come back with an entity or entities in a collection.
You can do a New Shape and only come out with the properties you want
for the object and still load it to a List<T>. If you have to query
again, you can query the List<T>.
Look at the example in the linq, and what is going to be generated and
executed behind the Linq-2-SQL query is T-SQL.
<
http://msdn.microsoft.com/en-us/vbasic/bb737925.aspx>
Is it possible to write a linq
Query against a dataTable contained within the app? How to do that?
Did you not look at the link below I gave you in the previous post?
<
http://dotnetarchitect.wordpress.com/2009/03/18/using-linq-to-manipulate-data-in-datasetdatatable/>
I am just the opposite of you. I will not use a dataset, datatable,
adapter, inline T-SQL or a sproc as long as there is Link-2-SQL or
ADO.NET Entity Framework, because objects are easy to use and are too
powerful not to use.
I made this post to someone earlier today. I'll make it to you too.
<copied>
The purpose of Linq is what?
Microsoft LINQ defines a set of query operators that can be used to
query, project and filter data in arrays, enumerable classes, XML,
relational database, and third party data sources. While it allows any
data source to be queried, it requires that the data be encapsulated as
*objects*. So, if the data source does not natively store data as
objects, the data must be mapped to the object domain. Queries written
using the query operators are executed either by the LINQ query
processing engine or, via an extension mechanism, handed over to LINQ
providers which either implement a separate query processing engine or
translate to a different format to be executed on a separate data store
(such as on a database server as SQL queries). The results of a query
are returned as a collection of in-memory *objects* that can be
enumerated using a standard iterator function such as C#'s foreach.
What is Linq-to-SQL?
LINQ to SQL, a component of Visual Studio Code Name "Orcas", provides a
run-time infrastructure for managing relational data as *objects*
without losing the ability to query. It does this by translating
language-integrated queries into SQL for execution by the database, and
then translating the tabular results back into objects you define. Your
application is then free to manipulate the objects while LINQ to SQL
stays in the background tracking your changes automatically.
The above holds true for ADO.NET Entity Framework, an ORM, and
Linq-2-Object and object encapsulation, inheritance and all that comes
with an object.
What is Object-oriented-programming?
(OOP) is a programming paradigm that uses "objects" and their
interactions to design applications and computer programs.
The key concepts of OOP are the following:
Class
Object
Instance
Method
Message passing
Inheritance
Abstraction
Encapsulation
Polymorphism
Decoupling
http://en.wikipedia.org/wiki/Object-oriented_programming
One gets use to using objects and things become simple.
![Smile :) :)](/styles/default/custom/smilies/smile.gif)