Label:Using EF's own small functions need to encounter inner join and group by combination of use and anonymous type of processing, search a lot, basically can not meet their own needs, so summed up also realized on their own write out, has been prepared to view and partner query Reference (General statement query does not say, the network search a lot) Statement query
Label:From C # in Depth (3rd)-Jon Skeet using (Linqdemodatacontext db = new Linqdemodatacontext ())
{
var filtered = from P in db. Products
joins s in Db. Suppliers on
p.supplierid equals S.supplierid
where P.price >
s.name, p.name
select new {s Uppliername = s.name, ProductName = p.name};
foreach (Var v in filtered)
{
Console.WriteLine ("Supplier={0}; Product={1} ",
v.suppliername, v.productname);
}
}
That's impressive enough, but if you ' re performance-conscious, you'll be wonderingWhy
Auxiliary classes1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Linq.Expressions;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceDrision.Framework.Logic.NYZF9 {Ten Public Static classPredicatebuilder One { A Public StaticExpressionBOOL>> truereturnf =true; } - Public StaticExpressionBOOL>> falsereturnf =false; } - the Public StaticExpressionBOOL>> or ThisExpressionBOOL>>Expr1, -ExpressionBOOL>>expr2) - {
criteria, and the corresponding grouping is found. However, the intermediate table we get is the group number. Then we have to convert the corresponding time according to the group number: Logtime=group_num*5/1440+to_date (date, ' Yyyy-mm-dd ') So: SELECT (To_date (DATE, ' yyyy-mm-dd hh24:mi ') + Group_num * 5/(each)) LogTimeSo we can query the condition by the point of time 1. The specific SQL statement
(0.00sec) then execute the following statement 1:mysql> SelectT1.id,t1.name,t2.id,t2.course,sum(t1.id) fromT1JoinT2 onT1.id=T2.idwhereT1.id=1 ;+----+-------+------+--------+------------+|Id|Name|Id|Course| sum(t1.id)|+----+-------+------+--------+------------+| 1 |Zhang| NULL | NULL | NULL |+----+-------+------+--------+------------+1Rowinch Set(0.00SecThe discovery unexpectedly has the output, then executes the following statement 2:Mysql> SelectT1.id,t1.name,t2.id,t2.course,sum(t1.id)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
[email protected]
and provide relevant evidence. A staff member will contact you within 5 working days.