Http://u.115.com/file/f2ce0eeb6 demo
The output sequence may not contain any element or element attribute of the source sequence. The output may be a sequence of values calculated by using the source element as an input parameter. When executing the following simple query, this query will output a string sequence, which indicates the calculation based on the source sequence of the double type element.
Description
If a query is converted to another domain, you cannot call a method in a query expression. For example, you cannot call a general C # method in LINQ to SQL, because SQL server does not have the context of this method. However, you can map stored procedures to methods and then call methods.
// Data source. double[] Radii = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Results. IEnumerable<string> Results = from Rad in Radii select String.Format("Area = {0}", (Rad * Rad) * 3.14); // Results execution. foreach (string Result in Results) Console.WriteLine(Result); // Keep the console open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey() // Data source.double[] Radii = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };// Results.IEnumerable<string> Results = from Rad in Radii select String.Format("Area = {0}", (Rad * Rad) * 3.14);// Results execution. foreach (string Result in Results) Console.WriteLine(Result);// Keep the console open in debug mode.Console.WriteLine("Press any key to exit.");Console.ReadKey()
The output is as follows:
Area = 3.14 Area = 12.56 Area = 28.26 Area = 50.24 Area = 78.5 Area = 113.04 Area = 153.86 Area = 200.96 Area = 254.34