Dale Fraser
Dale Fraser

Reputation: 4758

c# entity linq and linqpad differences

With a grouped query, when building by result I get different results

This works in LinqPad but not in code

Name = s.Key.FirstName + " " + s.Key.LastName ?? "Unknown User"

This works in Code but not in LinqPad

Name = s.Key.FirstName != null ? s.Key.LastName + " " + s.Key.LastName : "Unknown User"

This works in both

Name = String.IsNullOrEmpty(s.Key.FirstName) ? "Unknown User" : s.Key.FirstName + " " + s.Key.LastName,

Can anyone explain why

Upvotes: 0

Views: 157

Answers (1)

Maslow
Maslow

Reputation: 18746

LinqPad uses Linq2Sql by default.

The are certainly differences in the LINQ that works between EF and Linq2Sql. That is almost certainly what you are running into.

LINQ acts differently based on what provider actually runs the composed query. There are many more than this but it's a start:

You can write your own LINQ providers

Although if you tell Linqpad to add an EF library it will consume one you create:

adding an EF context to linqpad

Upvotes: 1

Related Questions