Hey, actually is a picture:
Joining multiple inputs to an output sequence
classStudent { Public stringName {Get;Set; } Public intAge {Get;Set; } Public stringCity {Get;Set; } Publiclist<int> Scores {Get;Set; } } classTeacher { Public intId {Get;Set; } Public stringName {Get;Set; } Public intAge {Get;Set; } Public stringCity {Get;Set; } }
Operation Code:
Public voidConcat () {//Create a First data source varStudents =NewList<student>() { NewStudent () { age= at, City="Guangzhou", Name="Small C", Scores=Newlist<int> () { -, the, the, the} }, NewStudent () { age= -, City="Guangxi", Name="Xiao Ming", Scores=Newlist<int> () { the, +, -, -} }, NewStudent () { age= -, City="in the Dream", Name="Little Three", Scores=Newlist<int> () { the, the, the, the} } }; //Create a second data source varTeachers =NewList<teacher>() { NewTeacher () { age= *, City="in the Dream", Name="Kiss" }, NewTeacher () { age= -, City="Yunnan", Name="Little Red" }, NewTeacher () { age= -, City="Henan", Name="Lili" } }; //Create our Contact varConcat = ( fromSinchStudentswhereS.city = ="Xindu" Selects.name). Concat ( fromTinchTeacherswhereT.city = ="Chongqing" Selectt.name); //Use our concat to connect our two datasets together; the effect is very good;}
2. Converting an in-memory object to XML
varStudents =NewList<student>() { NewStudent () { age= -, Name="Small A", Scores=Newlist<int> () { the, -, About, the } }, NewStudent () { age= *, Name="Small B", Scores=Newlist<int> () { the, -, About, the } }, NewStudent () { age= -, Name="Little What?", Scores=Newlist<int> () { the, -, About, the } } }; //Create a query varStudentstoxml =NewXElement ("Root", fromStudentinchstudents let X= $"{student. Scores[0]},{student. Scores[1]},{student. Scores[2]},{student. SCORES[3]}" Select NewXElement ("Student", NewXElement ("Name", student. Name),NewXElement (" Age", student. Age),NewXElement ("Scores", X)) )
Here to smooth the use of this let's drop ah;
In a LINQ query, a let clause can create a new scope variable and use that variable to save the node of the expression
$ "{Radius * radius * 3.14}" is equivalent to a string. Format ("{0}", radius * radius * 3.14), which uses the syntax of C # 6.0
LINQ Column Table