Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# list of unique values with group and 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 :: you have the following c# code. stringbuilder sb = new stringbuilder(really long string); the really long string variable is a string in which a very long string is stored. 
Csharp :: material.icons for wpf 
Csharp :: c# sha512 salt 
Csharp :: c# webclient accept all certificates 
Csharp :: log4net.dll 
Csharp :: afaik 
Csharp :: asp.net Read raw Body 
Csharp :: linq get values is not in other table 
Csharp :: can a dictionary type use get set c# 
Csharp :: C:UsersSherryDocumentssdata.dta 
Csharp :: how to read reportview query string asp.net c# 
Csharp :: c# if a new program is started 
Csharp :: ef core totable 
Csharp :: c# for loop Statement 
Csharp :: what is C# 
Csharp :: c# change chart legend font size 
Csharp :: c# class reference 
Csharp :: params keycord as var name c# 
Csharp :: ASP.NET Core set update clear cache from IMemoryCache (set by Set method of CacheExtensions class) 
Csharp :: unity3d spin wheel 
Csharp :: Unable to Write json variable c# getting an error 
Csharp :: there is no renderer attached to the gameobject 
Csharp :: sqldatareader get row count 
Csharp :: check the request comes from which operating system used by user in asp net core 
Csharp :: attributes C# reflection variable update site:stackoverflow.com 
Csharp :: asp.net core mvc not triggering client side validation 
Csharp :: how to get image from resource folder in c# 
Csharp :: extension of c sharp 
Csharp :: how to check if time is between two timespans in c# 
Csharp :: c# filesystemwatcher 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =