score:4
Accepted answer
var mails = from m in entity.mailboxes
join p in entity.ordinary_user_profile_info on m.from_id equals p.user_id
select new maillist
{
mid = m.m_id,
mfrom = m.from_id ?? 0,
mfomname = p.username,
msubject = m.subject
};
score:0
var mails = from m in entity.mailboxes
join p in entity.ordinary_user_profile_info on m.from_id equals p.user_id
select new maillist
{
mid = m.m_id,
mfrom = (int)m.from_id, // error occours here
mfomname = p.username,
msubject = m.subject
};
score:5
var mails = from m in entity.mailboxes
join p in entity.ordinary_user_profile_info on m.from_id equals p.user_id
select new maillist
{
mid = m.m_id,
**mfrom = m.from_id.hasvalue ? m.from_id.value : 0**
//this is saying is, since the int is nullable,
//if it has a value, take it, or return 0
mfomname = p.username,
msubject = m.subject
};
Source: stackoverflow.com
Related Query
- Can't get c# linq query to compile with joins
- Linq query NullReferenceException on multiple (cascade) left joins
- LINQ query with two joins that worked in EF 6 gives error in EF 7
- C# Linq Query with Multiple Joins with an await
- Same LINQ query using joins but different conditions
- Linq Query With Multiple Joins Not Giving Correct Results
- LINQ - Joins in a dynamic query
- Convert sql query with multiple inner joins to LINQ
- Linq query with two joins on inner select in EF
- Multiple Joins LINQ Query performance
- Dynamics CRM 2011 - Filtering LINQ query with outer joins
- Multiple JOINS with Conditions between them : LINQ query
- .net linq query joins
- Linq Query - Multiple Joins to one table
- Linq to Sql - Query list of distinct items with multiple joins
- LINQ query question, needs joins
- Optimizing a LINQ query with multiple joins and predicates
- Need help on LINQ query left joins and multiple fields
- LINQ syntax for SQL query with multiple inner joins and aliases
- How to return a child collection with joins linq query
- LINQ query with multiple joins and contains is not working
- Linq query with multiple joins and groups
- C# LINQ query with joins and multiple counts
- Linq query with multiple joins
- SQL to Linq query with multiple left outer joins
- Linq query syntax to method syntax when using multiple joins to introduce dynamic restrictions
- Recreating a large complex query with left outer joins in LINQ
- Unable to return list in linq query when using different tables with inner joins
- LINQ query with group joins and count needs refactoring
- CRM 2011 LINQ query with multiple inner joins and a single WHERE clause (VB .NET)
More Query from same tag
- LINQ Concate Two List To make one csv list
- Parse LINQ answer in a JSON
- Linq value, use Where to Remove items
- GroupBy - Project result to a list<T>
- Group elements based on two parameters
- Entity Framework Linq to Object Mapping
- "OR " condition in where clause of linq query is returning null
- Find XML element based on attributes
- How to use LINQ to get a single IENumerable<X> from a property of an IEnumerable<T>?
- Linq DataContext best practice
- How to Compare strings in Linq Query
- How to get last 10 mins records using linq?
- The member with identity ' ' does not exist in the metadata collection.\r\nParameter name: identity
- Linq: using let statement based on string to group data
- how use multiple join in linq?
- Linq to SQL count grouped elements generating a timeout
- Query with dynamic where clause (concatenated array elements)
- C# DataTable select columns where column name like
- Entity Framework - Using Navigation Properties over Joins
- C# Join Strings of two arrays
- check discontinuity of multiple ranges in a list
- translate row_number over partition to C# linq
- Populating data from database into multiple colums equally?
- How to add an additional filter to this XML
- IList.Select() that returns an IList (without copying)
- How can I count all items in multi-level list in linq
- List Manipulation in C# using Linq
- Loading LINQ results into a ViewModel that has a calculated attribute (column)
- How to write Linq depending if a value is provided or not
- Filter xml using xpath and linq (price with decimal separator and thousands separator spanish) VB. NET