Want to know convert linq query to sql query online? we have a huge selection of convert linq query to sql query online information on alibabacloud.com
Here are some operators that query data and then select the data again:First-returns one element in the collection;FirstOrDefault-Returns the first element in the collection (returns the default value if none);Last-Returns the final element in the collection;LastOrDefault-Returns the last element in the collection (default value if not)ElementAt-Returns the element of the specified index in the collection;Elementatordefault-Returns the element of the
If the data source does not implement the ienumerable
Data source: glistRange variable: GCode:
Public class guestinfo
{
Public string name {Get; set ;}
Public int age {Get; set ;}
Public String Tel {Get; set ;}
Public list
}
Class Program
{
Static void main (string [] ARGs)
{
Arraylist Glist = new arraylist ();
Glist. Add (New guestinfo {name = "Qian zhuowen", age = 20, tel = "110 "});
Glist. Add (New guestinfo {name = "Wu Guojun", age = 21, tel = "120 "});
Glist. Add (New gues
SQL statement join Table query and SQL statement join query
Answers to questions about SQL statement join Table query
1. Create two databases: Database A (table a) and database B (table B ).
2. allocate the same account permissi
LINQ to a table query, you can find a, B table, and then join a, B table, operation A, b combination of anonymous table Xvartable1= fromRinchSHITI.A () fromYinchR.yearswhereY> . Select New{ Year=y, name=R.firstname};varTable2= fromTinchshiti.b () fromYinchT.yearswhereY> . Select New{ Year=y, name=T.name} and then, based on these two queries, and then through clause join Tin
types, averaging; no delay
· Aggregate-Gets an aggregate value based on the input expression, without delay
· Cast-Converts the collection to a strongly typed collection;
· DefaultIfEmpty-The default value is returned when the query result is empty;
· SequenceEqual-Determines whether two sets are the same;
· OfType-Filters The specified type in the collection;
· ToArray-Converts the collection to an array;
· ToList-Converts the collecti
The following code finds the element greater than 5 in a 4*4 two-dimensional int array:
Static void main (string [] ARGs)
{
Int [,] array = new int [4, 4];
For (INT I = 0; I
For (Int J = 0; j
Array [I, j] = (I + 1) * (J + 1 );
VaR intquery = from I in array. Cast
Where I> 5
Select I;
Foreach (int I in intquery)
Console. writeline (I );
}
Because the two-dimensional array cannot be directly converted to the ienumerable The enumerable. Cast To the specified type.
This method
/// ///when the constructor uses true: single and valid, multiple and valid, single or invalid, multiple or invalid, or valid when mixed with and after///when the constructor uses false: single and invalid, multiple and invalid, single or valid, multiple or valid;/// Public Static classpredicateextensions{ Public StaticExpressionBOOL>> truereturnf =true; } Public StaticExpressionBOOL>> falsereturnf =false; } Public StaticExpressionBOOL>> or ThisExpressionBOOL>> expression1, ExpressionBOOL>>ex
Site9527entitiesdatacontext (important class): connects entity and website list operations
Spcontext. Current. Web. url: Get the page of the current operation
Firstordefault: Must be referenced before use (using system. LINQ ;)
Datacontext. submitchanges (): Make sure that the data is updated to the list.
Add
protected void bt_SaveClic(object sender, EventArgs e) { using (Site9527EntitiesDataContext dataContext = new Site9527Entities
Today, a customer said that when the copytodatatable method is used in the result set of the LINQ query, the resulting datatable is faulty. It was strange at the beginning. I searched the internet and found that this was indeed a problem.
Currently, the copytodatatable
Http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx
Have a nice day!
Generally if the logic is relatively simple, there are more than one query condition, and some situations do not need to add the query condition
Simple way to do it.
Public iqueryable
The multiple where condition here is an and relationship, and if it is a relationship, you can combine the results of multiple queries to union
Of course, most of the time, we want to be able to dynamically build
Most of the time, we have multiple query conditions, and the parameters are different, so the query conditions are different. In this case, we need to dynamically generate query conditions and then combine these query conditions. I found this category online, which can meet
{ Country = g.Key, Count = g.Count(),
// Before that, it is the same as before. Next, we sort and query the results of each group based on g, as if SQL is nested, then it becomes an anonymous object attribute Racers = from r1 in g orderby r1.LastName select r1.FirstName + "" + r1.LastName}; foreach (var item in countri
1. const string Text = @ "Historically, the world of data and the world of objects" + 2 @ "Have not been the integrated. Programmers work in C # or Visual Basic "+ 3 @" and also in SQL or XQuery. On the one side are concepts such as classes, "+ 4 @" objects, fields, inheritance, and. NET Framework APIs. On the other side "+ 5 @" are tables, columns, rows, nodes, and separate languages for de Aling with "+ 6 @" them. Data types often require translatio
Query xml and linqxml by using linq1. Load the xml string
XElement root = XElement. Parse (@ "XElement firstItem = root. Element ("Item"). Element ("Name"); // Name (Id: 1) under the first Item)Var descendants = root. Element ("Item"). Descendants ("Name"); // all names under the first Item (including the IDs of 1 and 1.1 in Children)Var xElements = root. Descendants ("Name"); // Name of all the children under root (Id: 1, 1.1, 2)
2. Directly load the
My Date
The first date format we get is this: 2009-2-12 or 2009-3-3 or 2009-10-12, we can do this by combining SQL statements: (three examples)
The code is as follows
Copy Code
@1select * from user where birthday> ' 2009-2-3 ' and birthday
This allows us to find all user information that includes 2009-2-3 and is greater than 2009-2-3.
@2 If that's how we mix it.
The code is as follows
Copy Code
);
+------+------+--------+------+------+--------------------+
| num | d_id | name | Age | sex | homeaddr |
+------+------+--------+------+------+--------------------+
| 1 | 1001 | Zhang San | 26 | Beijing hai Ding District |
+------+------+--------+------+------+--------------------+
1 row in Set (0.00 sec)
mysql>
2.4 Sub-query with any keyword The Any keyword means that any of these conditions are met, and when the Any
In fact, this is also a problem at work. To tell the truth, I am not willing to do it myself. I also want to write statements for queries, but I have not thoroughly studied this kind of information,Write SQL statements in JavaProgramAt the same time, I chose to be lazy.
First, if it is golden, of course there is no need to say that the Direct Write statement is similar to select. If it is PL/SQL, it is not
) Select DATEADD (Wk,datediff (Wk,0,getdate ()), 0) query yesterday Date: Select CONVERT (Char,dateadd (dd,-1,getdate)), 111 //111 is the style number, (100-114) query the first day of the month Date: Select DATEADD (mm, DATEDIFF (Mm,0,getdate ()), 0) as FirstDay query last day of the month Date: Select DATEADD (M S,-3
number of these bars, it is the next page 5, sort query Ascending //var list = con.car.OrderBy (r = r.price);//Sort a column of numeric types in a database table Descending //var list = Con.car.OrderByDescending (r = r.price); de-weight: var aaa = Con.car.Select (r = r.oil). Distinct (); 6, foreign key display return this.brand1.brand_name;//in a table with a primary foreign key relationship, when querying the foreign key table, you can poin
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.