9243 1
How to make Group by in Linq work with possible null values, in C#?

I am trying to add List.GroupBy(a=>a.ProductType.Name).Select(a=>a.FirstOrDefault()), now here I can have null values for .ProductType or .name so how can I ignore null values in C#, so I can get proper results of GroupBy?

If I am using above query in C#, I am getting error

Object reference not set to an instance of an object

I tried to make it like List.GroupBy(a=>a.ProductType != null ? a.ProductType), but it doesn't work.

...
Type
Question
9214 2
The UPDATE statement conflicted with the FOREIGN KEY constraint

When I am trying to save Updated data in table using Entity Framework in ASP.NET MVC, I am getting the below error

...
Type
Question
9209 1
Object Oriented Programming (OOPS) concepts in c# with example
OOP stands for Object Oriented Programming, in this article I have introduced you the concept of Object-Oriented Programming in C# with example
Type
Article
8907 0
How to get file extension or file size in C# ? ( Code With Example )
In this tutorial article, I have provided sample code with examples, which shows how to get file extension from file name and file size in C#
Type
Article
8805 0
Interface in C# (With Example)
In this article, I have explained about Interface in C#, when to use it and why do we need it with an example.
Type
Article


8718 0
Sealed Class in C# (Explanation with example)
This Article provides you complete information with working example of sealed class and methods in C# and how it can be useful for you.
Type
Article
8693 2
DbArithmeticExpression arguments must have a numeric common type

When I am trying to run this command using Entity framework in controller of my project

...
Type
Question
8650 0
Understanding Enums in C# & it's advantages with example
This article will give you introduction of Enums in C# and will help you understand where we should use it in real world and gives it advantages.
Type
Article
8431 0
Multiple ways to add newline into a String in C#
In this short article, I have provided multiple ways to add a line break into a string using C# with Console Application example.
Type
Article
8335 0
How to read and write in Console app using C#?
In this article, I have explained how to read and write in C# console applications using Console.ReadLine(), Console.WriteLine() methods in C# for basic, input and output using Console.
Type
Article

Page 8 of 24