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
scropio gurl
NA
147
99.3k
SQL to LINQ query no result
Jun 27 2016 4:06 AM
I try this SQL query and this query show results'
select
distinct
tblvv.MID,
tblrv.ownername,
from
tblvv
join
tblrv
on
tblrv.ID=tblvv.MID
join
tblre
on
tblre.RID = tblrv.RID
WHERE
tblre.Region =
'UK'
and
StartDate =
'2014-02-01 00:00:00.000'
AND
EndDate =
'2014-02-28 23:59:59.000'
order
by
tblrv.ownername
and then i try to convert this query in LINQ
try
{
DateTime frmdate =
Convert
.ToDateTime(fromdate.Value.Trim().Split(
'T'
)[0]);
DateTime tdatee =
Convert
.ToDateTime(todate.Value.Trim().Split(
'T'
)[0]);
string regionvalue = regiondrop.SelectedValue;
T1 ts = new Ts1();
var dq = (
from
vv
in
ts.tblvv
join
rv
in
ts.tblrv
on
vv.MID equals rv.ID
join
re
in
ts.tblre
on
rv.RID equals re.RID
where
re.Region == regionvalue
&& re.StartDate == frmdate
&& re.EndDate == tdatee
orderby rv.OwnerName
select
new
{
ownername = rv.OwnerName,
MID= vv.MID,
}).ToList();
GridView1.DataSource = dq;
GridView1.DataBind();
}
catch (Exception)
{
GridView1.Visible =
false
;
Label4.Text = (
"No Data"
);
}
but this above query not show any result
when i write || this sign on this line
&& re.StartDate == frmdate
like
|| re.StartDate == frmdate
then query shows so many records and this records are totally different from records which is in SQL query
also when i set break point there is not any error occurred
any solution?
Reply
Answers (
6
)
Some part of your SQL statement is nested too deeply.
IQueryable<T> and IEnumerable<T>