Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Good day
I need to interpret the following SQL to LINQ.
select
t1.req_no,
t1.seq_no,
t1.quantity,
t1.uom,
t1.item_name,
t2.event_date
from tb_cs_test t1, tb_cs_test2 t2 where (t1.req_no = 1 and t2.req_no = 1 );
I use MVC and with this SQL Statement i need to throw the requested fields based on the condition that I put
Thanks
You can do that with a JOIN:
from t1 in tb_cs_test
join t2 in tb_cs_test2
on t1.req_no equals t2.req_no
where t1.req_no = 1
select new {
t1.req_no,
t1.seq_no,
t1.quantity,
t1.uom,
t1.item_name,
t2.event_date
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Hi guys I need some direction with how to layout a group and sum of a variable from within an XML file on C#.
The XML document is as follows:
<xxxx>
<yy>
<pp a= "b">
<aa> 3 </aa>
</yy>
<yy>
<pp a= "c">
<aa> 5 </aa>
</yy>
<yy>
<pp a= "b">
<aa> 6 </aa>
</yy>
</xxxx>
How would I go about creating a C# Linq query to group attributes(a) and sum the (aa) element totals?
Something like this?
from d in xmldoc.Descendants("yy")
group d by d.Element("pp").Attribute("a").Value into dg
select new { a = dg.Key, sum = dg.Sum(d => Int64.Parse(d.Element("aa").Value)) }
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
If I had the table "CustomerDetails" than what is the below query explains??
var details = (from data in entity.CustomerDetails where (data.CustomerId == CustId && data.CustomerProjectID == CustProjId) select data).FirstOrDefault();
Share the exact meaning. Thanks in advance.
That query selects the data from the CustomerDetails table where the CustomerId equals the given CustId and the CustomerProjectID equals the given CustProjId. It then returns the first element from the set that returns.
I personally find it easier to use LINQ Expressions like so:
var details = entity.CustomerDetails
.FirstOrDefault(cust =>
cust.CustomerId == CustId &&
cust.CustomerProjectID == CustProjId
);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i have 2 data table have same column and contain value.I want to compare data from both table and find the missmatching data in another table 2.Both table contain 38 column each.
Select
CASE WHEN t1.value = t2.value THEN 'True' ELSE 'False' END AS Result
From Table1 t1
Inner Join Table2 t2 on t1.ID = t2.ID
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am doing a kind of Join in my MVC application by using LINQ as,
var temp= (from enumeration in db.Enumerations
join cust in db.Customers on Convert.ToInt32(enumeration.Value) equals cust.lkpStatus
where (cust.ID==data.ID &&
enumeration.EnumerationTypeID.Contains("Customer.lkpStatus") )
select enumeration).FirstOrDefault();
In this I have got a Problem on Join is that "enumeration.Value" is a string value and " cust.lkpStatus" is an int.
So how can be the query to do joining by using the LINQ. Please suggest some LINQ query in this scenario.
try with SqlFunctions.StringConvert
join cust in db.Customers on
enumeration.Value equals SqlFunctions.StringConvert((decimal) cust.lkpStatus).Trim()
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
What's the linq to sql translation for this query
SELECT *
FROM MasterTable AS [t0]
Outer APPLY UfnGetDetail([t0].x, [t0].y, z) AS [t2]
...
Ok, it works with something like this
var query = from mt in db.MasterTable
let detailResult = db.UfnGetDetail(mt.x, mt.y, z).SingleOrDefault()...
Have you tried this:
from mt in dc.MasterTable
select dc.UfnGetDetail (mt.x, mt.y)