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
Guest User
Tech Writer
15
6.2k
SQL to LINQ Conversion
Feb 8 2019 2:45 AM
Hello.. I'm new to LINQ to SQL using C#. I am wondering if this Query is convertable to LINQ ?
SET
@cnt = 0;
SET @Company = @CompCode
select
TOP
1 @cdate =
convert
(
date
,DateReleased)
from
IRForm
WHERE
Company = @Company
set
@cdate = (
select
TOP
1
convert
(
date
,DateReleased)
from
IRForm
WHERE
Company = @Company)
select
TOP
1 @cnt =
COUNT
(Company)
from
IRForm
WHERE
Company = @Company
AND
convert
(
date
,@cdate) =
convert
(
date
,@dn)
set
@cnt = (
select
TOP
1
COUNT
(Company)
from
IRForm
WHERE
Company = @Company
AND
convert
(
date
,@cdate) =
convert
(
date
,@dn))
IF (@cnt = 0)
BEGIN
INSERT
INTO
IRForm (
IR_No,
Subj_Desc,
Subj_Code,
Company,
Incident_Date,
Reported_By,
Mpad_SN,
User_No,
A_S_B,
Person_Involved,
DT_Recieved,
Incident_Desc,
OS_Name,
OS_Submitted)
VALUES
(
@Company + FORMAT( @dn,
'yy/MM/'
,
'en-US'
) +
'00'
+
CAST
(@cnt + 1
as
varchar
(10)),
@Subj_Desc,
@Subj_Code,
@Company,
@Incident_Date,
@Reported_By,
@Mpad_SN,
@User_No,
@A_S_B,
@Person_Involved,
@DT_Recieved,
@Incident_Desc,
@OS_Name,
@OS_Submitted)
END
If yes, please provide me an example so that I can continue learning LINQ. Thank you C# Corner.
Reply
Answers (
2
)
convert string values to itextsharp.text.rectangle in vb.net
How to remove \ from data having ' after parsing json