Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

LINQ return list of unique values with counts

// model
 public class orderviewmodel
    {
        public string OrderNumber { get; set; }
        public int Count { get; set; }
    }
    
 // BL
  public IList<orderviewmodel> Read(string tmpC)
        {
            try
            {
                using (var entities = new UrEntities())
                {
                    return entities.Masters.Where(w => w.ContainerNumber.Equals(tmpC)).GroupBy(g => g.OrderNumber)
                        .Select(s => new orderviewmodel { OrderNumber = s.Key, Count = s.ToList().Count,  }).ToList();
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# move picturebox 
Csharp :: check if variable less than in f# 
Csharp :: c# increment by 2 
Csharp :: check null type 
Csharp :: how to do if statement based on date in asp net c# 
Csharp :: how to preset an array c# 
Csharp :: Query mongodb collection as dynamic 
Csharp :: get the next letter after specific character in c# 
Csharp :: hardcode dropdown cshtml 
Csharp :: Retrieving a value in one class that is set in another 
Csharp :: c# void with nullable List argument 
Csharp :: CefSharp.Core in clickones application 
Csharp :: best free Modern Design frameworks C# 
Csharp :: xamarin forms uwp button hover 
Csharp :: ienumerable tolist 
Csharp :: two question marks together mean in C# 
Csharp :: c# linq unique by property 
Csharp :: catwherehouse 
Csharp :: how to initialize array in c# 
Csharp :: c# string is all zeros 
Csharp :: c# unzip all archive files inside directory 
Csharp :: unity AppDomain 
Csharp :: how to move the camera rotation in phone in c# by touch 
Csharp :: windows form button border color 
Csharp :: unity photon base onenable 
Csharp :: leantween unity when timescale 0 
Csharp :: xamarin forms set the grid row property of an element programmatically 
Csharp :: ef core identity get user with relationships 
Csharp :: c# sort word 
Csharp :: how to make projectile track and go to specified enemy in unity 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =