how to use LINQ in entity frame work [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am a beginner in Entity framework , I want to use LINQ in EF. so please guide me from where i should start learn, what is the basic resources for this .

Try these two links
http://msdn.microsoft.com/en-us/data/ff628210.aspx
http://msdn.microsoft.com/en-us/library/bb386964.aspx
The best way to learn is to use them in the real projects

There are basically three ways you can query data in EF:
LINQ To Entities - Uses standard LINQ operators; more intuitive
Entity SQL - Syntactically similar to TSQL; targets Conceptual Schema directly
Query Builder Methods - Uses Extension Methods defined on IEnumerable and IQueryable
LINQ To Entities is the most preferred way followed by Query Builder Methods.
You can start by understanding most common operators used with LINQ To Entities. Eg., from, join, into, let, group by, order by, select, etc.

Related

Advantage of Linq over direct SQL queries? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
What are the effects of Linq on an application rather than SQL queries?
Is there is any issue in using Linq in case of large amount of data for a long time of period?
What are the behavioral key difference between both?
Simple advantages
Creating in-memory collections
for a number of situations it would be easier to read and write. (note there are some queries that would make more sense in SQL)
Allows you to call C# functionality that you create or from the .net framework to interact with your data.
In some cases it is easier to debug.
For a more in depth and correct answer go to Learning about LINQ

C# Optional params for build sql string best way [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
i'm trying to see which is the best way or practise for sql string optimizations in c#, mssql. What i'm trying to do is like a crud system where we send the necessary required params such as db name and table and after we have the conditional, for example if its a remove action, we will have an where condition and it can contain more than 1 param so what i wanna know is get the whole params.
Should i accept an array with those conditions or what i must do.
Thanks
Not exactly an answer to your question but you should consider using ORM tool like NHibernate.
With NHibernate, you can accept QueryCriteria or ICriteria from outside world which will do the query accordingly.
Be warned that this will be big change in your application and NHibernate have steep learning curve.
There are also simple micro-ORMs available like Dapper. With it, you can implement Repository pattern by creating Data Access Layer. Refer this link.

How to combine EF and ADO? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
After reading forums and articles, I found that using the Entity Framework
you can quickly create a database, and ADO can be used to conventional SQL queries and get accurate results. Also there are many questions all over the internet: what is better, ADO or EF? And in responses saying that need to combine these two technologies, each in its own good. But here's the question of how combine these two technologies and use them in the same project?
For example, i have several tables that mapped to entites, like employee and tasks. With EF i can create new employees and add them to database. But what if i want to create a report, that can be easely created with complex SQL query from many tables. The result of this SQL query can't match existing entities, so what to do? Create new entity-model to match this report and create this LINQ query to build it, or use ADO and SQL query?
EF actually use ADO deep inside itself.
If you want to execute plain SQL in EF you can use theese methods:
SqlQuery() //for selects
ExecuteSqlCommand() //for Delete, Insert, Update
Check msdn.

When to ditch LINQ? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
LINQ just seems to generate horrendously optimised SQL (in general). I can write way more efficient T-SQL myself.
Do huge websites with my thousands of daily visitors use LINQ? Or should LINQ at some point be ditched? And if so, with what? and when?
Do huge websites with my thousands of daily visitors use LINQ?
Yes. Why not? Most SQL is trivial and you can always fall back to a stored procedure where it matters.
And that is the point. Let LINQ handlethe easy 80% and focus on the more complex.
And ther rest you handle by not talking to the database - caching is not that hard to plan for.
What I have done with my apps, when L2S or EF creates inefficient T-SQL is to create a view that does exactly what I want, in an efficient manner and I just have L2S or EF query the view.
In fact, this website (stackoverflow) uses linq2sql extensively, although I believe they are using a micro-orm (sqlfu?) for some of the heavier taks..

LINQ using C#.net [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How to get started learning LINQ in C#.net.
LINQ is a pretty big subject.
I would start with Hooked On LINQ
The way I learned Linq was from the book Linq in Action
Get LinqPad!
Its a great way to learn LINQ, supports LINQ to SQL, LINQ to Objects and LINQ to XML, and it comes preloaded with 200+ examples from the book C# 3.0 in a Nutshell.
The MSDN Getting Started With LINQ Page was helpful to me.
The videos at http://www.asp.net/learn/ are great. They have an entire section on Linq that will take you from "new solution" to fully working examples.
http://www.asp.net/learn/linq-videos/
I'm a long-time SQL developer, and I found that all I needed for the transition to learning LINQ was 101 LINQ Samples off of msdn. All the basics are there, if you understand the generalities of a query-based syntax already. I don't know what your existing expertise is, so thought I'd throw that out there.

Categories