TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
S VK
NA
18
0
linq to display data in matrix form
Nov 2 2017 1:15 AM
table as data as below
Id Std Div Count Cvalue
1 one A 50 Nos
2 one B 30 Nos
3 one C 40 Nos
4 one D 24 Nos
5 Two A 32 Nos
6 Two B 54 Nos
7 Two C 33 Nos
8 Two D 45 Nos
9 Three A 32 Nos
6 Three B 54 Nos
7 Three C 33 Nos
8 Three D 45 Nos
and so on ...
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'
)
I need to display data in view from database in matrix form as
i am not getting result with the below query
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);
Reply
Answers (
1
)
display data from database base on date
Security in .net core