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
ahmed elbarbary
NA
1.6k
277.8k
How to write web API make by entity framework by ADO.NET ?
Feb 24 2020 7:02 AM
problem
How to write web API make by entity framework by ado.net ?
I work on SQL server 2012 with asp.net core 2 .
I need to rewrite web API below but with ado.net
so that how to make that ?
database blow :
CREATE
TABLE
[dbo].[
User
](
[Id] [
int
] IDENTITY(1,1)
NOT
NULL
,
[FirstName] [nvarchar](250)
NULL
,
[LastName] [nvarchar](250)
NULL
,
[Email] [nvarchar](250)
NULL
,
[Phone] [nvarchar](50)
NULL
,
CONSTRAINT
[PK_User]
PRIMARY
KEY
CLUSTERED
(
[Id]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, _
ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
GO
/****** Object:
Table
[dbo].[UserMarks] Script
Date
: 8/15/2018 9:22:00 AM ******/
SET
ANSI_NULLS
ON
GO
SET
QUOTED_IDENTIFIER
ON
GO
CREATE
TABLE
[dbo].[UserMarks](
[id] [
int
]
NOT
NULL
,
[userId] [
int
]
NULL
,
[mark] [
decimal
](18, 2)
NULL
,
CONSTRAINT
[PK_UserMarks]
PRIMARY
KEY
CLUSTERED
(
[id]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, _
ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
What I have tried:
[HttpGet, Route(
"GetResult"
)]
public
async Task<List<vmMarks>> GetResult()
{
List<vmMarks> query =
null
;
try
{
using
(_ctx)
{
query = await (from um
in
_ctx.UserMarks
join m
in
_ctx.User on um.UserId equals m.Id
select
new
vmMarks
{
mid = (
int
)m.Id,
mName = m.FirstName +
" "
+ m.LastName,
mMark = (
decimal
)um.Mark
}).OrderByDescending(x => x.mMark).ToListAsync();
}
}
catch
(Exception ex)
{
ex.ToString();
}
return
query;
}
Reply
Answers (
3
)
How to Send/Receive text file over 1553 Card?
C# application not showing to other AD users in laptop