tagged [linq]

If Else in LINQ

If Else in LINQ Is it possible to use If Else conditional in a LINQ query? Something like

2 Jun at 12:46

How to achieve Left Excluding JOIN using LINQ?

How to achieve Left Excluding JOIN using LINQ? How to achieve Left Excluding JOIN using LINQ? In [SQL](http://www.codeproject.com/KB/database/Visual_SQL_Joins.aspx):

12 Jul at 10:38

casting a tiny int from SQL server

casting a tiny int from SQL server I'm using linq to sql to populate a list of objects. One of the fields I'm interested in is stored as a tinyint. How should I declare this property type in my object...

17 Feb at 20:25

Is null checking required for IEnumerable object?

Is null checking required for IEnumerable object? From the above statement, do i need to variable

6 May at 02:51

Count values in Dictionary using LINQ and LINQ extensions

Count values in Dictionary using LINQ and LINQ extensions I have a dictionary that looks something like this: How can I get a count of all the values using LINQ and LINQ extensions?

How can I conditionally apply a Linq operator?

How can I conditionally apply a Linq operator? We're working on a Log Viewer. The use will have the option to filter by user, severity, etc. In the Sql days I'd add to the query string, but I want to ...

1 Jul at 09:40

Get table-data from table-name in LINQ DataContext

Get table-data from table-name in LINQ DataContext I need to get table data from table name from Linq DataContext. Instead of this I need to do something like this. It could be any table name that is ...

8 Jul at 15:54

Linq: Difference between 2 DateTimes in TimeSpan

Linq: Difference between 2 DateTimes in TimeSpan I'm trying to do this: ``` Tickets.Where(t => (t.Date - myTicket.Date)

18 Apr at 18:0

Difference Between Select and SelectMany

Difference Between Select and SelectMany I've been searching the difference between `Select` and `SelectMany` but I haven't been able to find a suitable answer. I need to learn the difference when usi...

24 Nov at 23:47

How to Remove multiple items in List using RemoveAll on condition?

How to Remove multiple items in List using RemoveAll on condition? I tried like following. Instead how can I do something like:

16 Jul at 13:45

Bulk-deleting in LINQ to Entities

Bulk-deleting in LINQ to Entities Is there any way to bulk-delete a bunch of objects matching a given query in LINQ or LINQ-to-Entities? The only references that I can find are outdated, and it seems ...

LINQ identity function

LINQ identity function Just a little niggle about LINQ syntax. I'm flattening an `IEnumerable>` with `SelectMany(x => x)`. My problem is with the lambda expression `x => x`. It looks a bit ugly. Is th...

14 Oct at 03:42

LINQ: dot notation equivalent for JOIN

LINQ: dot notation equivalent for JOIN Consider this LINQ expression written using query notation: ``` List pr = (from p in db.Persons join e in db.PersonExceptions on p.ID equals ...

25 Oct at 11:32

Converting array of objects to XML in C#

Converting array of objects to XML in C# I know there's no built in converter to convert an array of objects to XML. Is there a quick rudimentary way to create a XML out of the array to help me do a L...

14 Oct at 17:46

FirstorDefault() causes lazy loading or eager loading for linq to sql

FirstorDefault() causes lazy loading or eager loading for linq to sql What is default behavior of FirstOrDefault() when used with Linq to SQL? For e.g

31 May at 14:50

How to inner join tables from different Data Context?

How to inner join tables from different Data Context? I have two tables from two different Data Contexts. Although both tables are from the same database, two separate datacontexts exist. Error messa...

4 Mar at 05:33

Cast string as Guid using LinqPad

Cast string as Guid using LinqPad When I run following in the LinqPad it gives me > Cannot implicitly convert type 'string' to 'System.Guid' I just don't know how to apply proper cast it to GUid I gue...

15 Jun at 19:4

How to create a dynamic LINQ join extension method

How to create a dynamic LINQ join extension method There was a library of dynamic [LINQ](http://en.wikipedia.org/wiki/Language_Integrated_Query) extensions methods released as a sample with [Visual St...

What's your favorite LINQ to Objects operator which is not built-in?

What's your favorite LINQ to Objects operator which is not built-in? With extension methods, we can write handy LINQ operators which solve generic problems. I want to hear which methods or overloads y...

LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)' method

LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)' method I try to select records in database in 60 days 30 days 20 days differents in current date. Please see ...

Remove duplicates in the list using linq

Remove duplicates in the list using linq I have a class `Items` with `properties (Id, Name, Code, Price)`. The List of `Items` is populated with duplicated items. For ex.: H

22 Oct at 12:26

Linq distinct & max

Linq distinct & max I have to query this table: I need for all distinct value. How do I have to write my linq query? Thanks in advance,

18 Apr at 07:24

Get All Except from SQL database using Entity Framework

Get All Except from SQL database using Entity Framework I have a list of Products like this There is an entity called Products, I want to get all elements from products except those exist in associate...

LINQ to SQL value BETWEEN two double values

LINQ to SQL value BETWEEN two double values I'm using LINQ to SQL to query my database, I have a query very similar to this: I need the where clause to have a `d.Proce >= minValue`, and `d.Price =

12 Sep at 11:43

Using LINQ to parse the numbers from a string

Using LINQ to parse the numbers from a string Is it possible to write a query where we get all those characters that could be parsed into int from any given string? For example we have a string like: ...

13 Aug at 21:12