Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
6
Reply
SQL to LINQ query no result
scropio gurl
Jun 27 2016 4:06 AM
427
Reply
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?
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
Some part of your SQL statement is nested too deeply.
IQueryable<T> and IEnumerable<T>