select ROW_NUMBER() over (partition by m.Rack order by m.Id) RackWiseSerialNo, m.Id, m.Rack, m.Capacity, s.BatchId, s.SampleQty from [MstStorage] M LEFT JOIN [tblStorageBatch] S ON M.Id=S.StorageId
-------
My Code is like
_TestRetensionList = (from MstStorage in _dbContext.MstStorage.Where(k => k.IsActive == ApplicationData.IsActive) join TblStorageBatch in _dbContext.TblStorageBatch on MstStorage.Id equals TblStorageBatch.StorageId into TblStorageBatch from m1 in TblStorageBatch.DefaultIfEmpty() select new { Id = MstStorage.Id, Row = MstStorage.Row, Shelf = MstStorage.Shelf, Tray = MstStorage.Tray, Capacity = MstStorage.Capacity, LabId = MstStorage.LabId, BatchId = m1.BatchId, SampleQty = m1.SampleQty, Rack = MstStorage.Rack
}).AsEnumerable().Select((k, index) => new TestRetensionList() {
Id = k.Id, Row = k.Row, Shelf = k.Shelf, Tray = k.Tray, Capacity = k.Capacity, LabId = k.LabId, BatchId = k.BatchId, SampleQty = k.SampleQty, Rack = k.Rack, LeftQty = (k.Capacity - k.SampleQty), RackWiseSerailNo= ?? Statuscolor = Statuscolor((int)(k.Capacity - k.SampleQty), k.SampleQty).Result, btnvisible = BtnVisibility((int)(k.Capacity - k.SampleQty), k.SampleQty).Result, }).ToList();