This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
LINQ Inner-Join vs Left-Join
How can i implement left join in LINQ?
plz provide me sample code.
have a look on Left Outer Joins
Related
This question already has answers here:
Difference between Laravel DB::insert() and DB::table()->insert()
(3 answers)
Closed 1 year ago.
what is the differences of following two:
DB::update(
'update users set votes = 0 where votes < 0'
);
DB::transaction(function () {
DB::table('users')->where('votes', '<' , 0)->update(['votes' => 0]);
});
Official Laravel doc says
The update method should be used to update existing records in the database
But transaction seems more handful that can react to exceptions.
So in what scenarios one is better than the other?
The DB::update() is for raw sql queries on the other hand DB::table()->update is for query builder. Query builder is much more efficient as it prepares and binds the statements itself.
The question has been answered here
This question already has answers here:
Oracle DB: How can I write query ignoring case?
(9 answers)
Closed 4 years ago.
I am working with database where i need to retrieve distinct values. Example [English enGLish english ....] all this should be displayed as English only. Can anyone tell me how to achieve this.
Thanks in advance
Looks like you need function initcap():
demo
select distinct initcap(column_name) from your_table
This question already has answers here:
C# Linq Where Date Between 2 Dates
(9 answers)
Closed 7 years ago.
What is the Syntax to use Between Keyword in LINQ? Is it possible to use BETWEEN keyword in LINQ?
Awaiting for the response.
Thanks
You can use >= and <=.
Look similar question
This question already has answers here:
LINQ : Dynamic select
(12 answers)
Closed 8 years ago.
I'm working with dynamic queries using LINQ on Entity Framework.
To query some tables by user input filters, we are using PredicateBuilder to create conditional WHERE sections. That works really great, but the number of columns returned are fixed.
Now, if we need the user to select which columns he needs in their report, besides their filters, we are in trouble, as we don't know how to do dynamic myQuery.Select( x => new { ... }) as we do for Where clause.
How can we achieve something like this?
A bit of searching reveals that this is tricky. Anonymous types are created at compile time, so it is not easy to create one dynamically. This answer contains a solution using Reflection.emit.
If possible, I would recommend just returning something like a IDictionary<,> instead.
This question already has answers here:
Understanding .AsEnumerable() in LINQ to SQL
(4 answers)
C# - AsEnumerable Example
(10 answers)
Closed 9 years ago.
I am new to LINQ. my question is why do we use asenumerable() in query when we can get out answer without even using it. i want my concept to be cleared about asenumerable() function. please help.