linq to display data in matrix form

Thread is closed for posting
1 posts, 0 answers
  1. Surekha
    Surekha avatar
    2 posts
    Member since:
    Oct 2017

    Posted 02 Nov 2017 Link to this post

    DECLARE @Test AS TABLE(Id INT,Std CHAR(10),Div CHAR(10),[Count] INT,Cvalue CHAR(10))  
    INSERT INTO @Test VALUES(1,'one','A',50,'Nos')  
    INSERT INTO @Test VALUES(2,'one','B',30,'Nos')  
    INSERT INTO @Test VALUES(3,'one','C',40,'Nos')  
    INSERT INTO @Test VALUES(4,'one','D',24,'Nos')  
    INSERT INTO @Test VALUES(5,'Two','A',32,'Nos')  
    INSERT INTO @Test VALUES(6,'Two','B',54,'Nos')  
    INSERT INTO @Test VALUES(7,'Two','C',33,'Nos')  
    INSERT INTO @Test VALUES(8,'Two','D',45,'Nos')  
    INSERT INTO @Test VALUES(9,'Three','A',32,'Nos')  
    INSERT INTO @Test VALUES(10,'Three','B',54,'Nos')  
    INSERT INTO @Test VALUES(11,'Three','C',33,'Nos')  
    INSERT INTO @Test VALUES(12,'Three','D',45,'Nos')  

     need to display data in view from database in matrix form as

     

     

     

    var model = (from p in db.std 
    group p by p.Std into g 
    select new DataViewModel 
    rowKey = g.Key, 
    rowData = g.Select(s => new P1DataViewModel {Div= s.Div ,count= s.Count }).ToList() 
    }).ToList(); 
    return View(model);
    from above i am not getting the resukt
Back to Top