score:0
Accepted answer
Since ModType is nullable, it did not return what I was expecting. The code should be...
return seg => seg.ModType == Deleted &&
seg.Line.Segments.Any(segs => segs.ID != seg.ID &&
(segs.ModType != Deleted || segs.ModType == null));
Thanks to all those who replied and gave comments and suggestions!
score:0
Instead of Any(), use Where(), which will return you an IEnumerable object. Like Jon says, Any() returns a boolean.
score:2
I'd think it would be something like:
return s => from segment in s.Line.Segments
where segment.ModType == Deleted
&& segment.Line.Segments.Any(segs => segs.ModType != Deleted)
select segment
Source: stackoverflow.com
Related Query
- C# Lambda Expression not returning expected result
- Lambda expression not return correct result when using All()
- Any() is not returning expected result -- alternatives?
- Read CDATA from xml using LINQ not returning expected result
- Linq query with negated condition in Any not returning the expected result
- An expression tree lambda may not contain a null propagating operator
- Cannot convert lambda expression to type 'string' because it is not a delegate type
- Cannot convert lambda expression to type 'object' because it is not a delegate type
- Extension method returning lambda expression through compare
- Cannot convert lambda expression to type 'string' because it is not a delegate type
- "Does Not Contain" dynamic lambda expression
- Cannot convert lambda expression to type 'string' because it is not a delegate type
- Assigning a lambda expression causes it to not be executed later?
- Cannot convert lambda expression to type 'string' because it is not a delegate type - OrderBy and DbGeography by ref
- Lambda expression to return one result for each distinct value in list
- Is there any extension method which get void returning lambda expression ?
- "Cannot convert lambda expression to type 'string' because it is not a delegate type" querying dataset in C#
- OrderBy().ThenBy().ThenBy() not giving expected result on a List of entities
- join not returning all elements in left table C# lambda
- 'The LINQ expression node type 'Invoke' is not supported in LINQ to Entities' when lambda is passed as a parameter, but not when used directly
- How to Solve this Error "Cannot convert lambda expression to type 'string' because it is not a delegate type"
- Cannot convert lambda expression to type 'bool' because it is not a delegate type
- Lambda Expression with a statement body can not been converted
- Lambda expression used inside Include is not valid. EF6, Navigation Property
- Linq lambda expression throwing error if result set is null
- Lambda Expression for Many to Many realtionship in C# EF 5 Code First
- Cannot convert lambda expression to type int because it is not a delegate type
- Moq callback method not hit within lambda expression
- The LINQ lambda expression not working
- LINQ query not returning desired result as string. Why?
More Query from same tag
- How would I obtain a total sum of only selected rows for a specific column?
- Dynamically select columns in LINQ statement
- Multiple MDF FIles VS Single DataBase(SQL Server)
- Linq to EF: find the nearest Nullable Datetime from now
- Get Attribute Values using LINQ to XML with Unknown Elements
- How to create dynamic Multiple And linq conditions in foreach loop
- Delete function skipped in asp.net
- Possible to use anonymous type members during declaration?
- linq to sql return only match based on ID
- A problem with compare item value
- Linq Reverse -does it leave the variable changed or make a copy
- How to Load Related Data in MVC with complex table structure
- LINQ Join on a Nullable key
- Using ExpressionVisitor to modify expression for automatic translations
- How to make LINQ to multiple tables
- Convert String to Float in LINQ
- Grouping by range of values with linq and entity framework
- Linq query with 3 tables
- LINQ C# Calculating a List value using 2 lists
- How to create a fully dynamic linq query?
- Count of distinct with linq to entities and custom IEqualityComparer
- Add index position Value of an array of array using Linq
- LINQ to Entities, join two tables, then group and take sums of columns from both tables
- Previous non-empty value in a DateTime LINQ join
- InvalidOperationException when enumerating through a list of results to provide multiple textbox's with text
- How to order by 1 expression or 2 expressions based on a condition?
- Filter linq list on property value
- How to simplify repetitive OR condition in Where(e => e.prop1.contains() || e.prop2.contains() || ...)
- Only primitive types ('such as Int32, String, and Guid') are supported in this context when I try updating my viewmodel
- create a dynamic selectlist with distinct values from LINQ