ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Can you tell me what this "Id" is?So that we can help you better. It is best to give the table structure you use.
I assume that Id is a table, and convert the code you gave.
var query = from H in db.Headers
join BD in db.RangeDetailss on H.ID equals BD.HeaderId into BD2
from BD1 in BD2
from t in db.TestIds
where t.Quantity >BD1.MinQty && t.Quantity < (BD1.MaxQty.ToString() == null ? t.Quantity : BD1.MaxQty)
select H;
This is the fields I wrote out according to your code.
public class RangeDetails{
[Key]
public int HeaderId { get; set; }
public int MinQty { get; set; }
public int MaxQty { get; set; }
}
public class Header
{
public int ID { get; set; }
public string testname { get; set; }
}
public class TestId
{
public int ID { get; set; }
public int Quantity { get; set; }
}
Best Regards,
YihuiSun
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
3 Points
14 Posts
Linq Query Help | Between Condition in Left Join
Jun 12, 2020 02:41 PM|sekharvbm|LINK
Hey Guys,
Can you please help me on below query how to convert this to Linq
Select * from billing.Header H
LEFT JOIN Billing.RangeDetails BD ON BD.HeaderId = H.ID AND Id.Quantity between BD.MinQty and Isnull(BD.MaxQty,Id.Quantity)
Thanks
Sekhar G
Contributor
3090 Points
877 Posts
Re: Linq Query Help | Between Condition in Left Join
Jun 15, 2020 11:43 AM|YihuiSun|LINK
Hi, sekharvbm
What is the "H" in the code you gave? What is "Id"? What is "Isnull"?
Remarks:A nice tool for SQL to LINQ transition:https://dzone.com/articles/linqer-%E2%80%93-nice-tool-sql-linq
Best Regards,
YihuiSun
Member
3 Points
14 Posts
Re: Linq Query Help | Between Condition in Left Join
Jun 16, 2020 06:54 PM|sekharvbm|LINK
'H' is an alias name for Billing.Header
Linqer is an genuine ?
Thanks,
Sekhar G
Contributor
3090 Points
877 Posts
Re: Linq Query Help | Between Condition in Left Join
Jun 19, 2020 07:11 AM|YihuiSun|LINK
Hi, sekharvbm
Can you tell me what this "Id" is?So that we can help you better. It is best to give the table structure you use.
I assume that Id is a table, and convert the code you gave.
This is the fields I wrote out according to your code.
Best Regards,
YihuiSun