Loading editor...
1. onett has a field AA BB CC
2. twott has an ee ff bb Field
Two table connection queries,
List <multable> Mul = (from a in _ dB. onettt join B in _ dB. twottt on A. BB equals B. BB where a. BB! = "" Select new multable {AAA =. AA, BBB =. BB, eee = B. ee, fff = B. ff }). tolist <multable> (); foreach (multable item in Mul) console. writeline (item. AAA + item. BBB + item. EEE );
class multable {Public String AAA = string. empty; Public String BBB = string. empty; Public String EEE = string. empty; Public String fff = string. empty; Public override string tostring () {return string. format ("AAA: {0}, BBB: {1}, eee: {2}, fff {3}", AAA, BBB, eee, fff );}}
String [] weekdays = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday "}; // see the above Code, the ienumerable <string> weekdayswithlength is the explicit object, Here var weekdayswithlength is implicit object, which will convert by assign type. // var weekdayswithlength = from W in weekdays where W. length> 1 orderby W select W; string [] weekdayswithlength = (from W in weekdays where W. length> 1 orderby W select W ). toarray <string> (); // listbox1.items. clear (); foreach (string STR in weekdayswithlength) console. writeline (STR); List <car> mycars = new list <car> {new car {color = "Silver", make = "BMW", petname = "Henry ", speed = 100}, new car {color = "Tan", make = "BMW", petname = "Daisy", speed = 90}, new car {color = "black ", make = "VW", petname = "Mary", speed = 55}, new car {color = "Rust", make = "Yugo", petname = "clunker ", speed = 5}, new car {color = "white", make = "Ford", petname = "melvin", speed = 43 }}; list <car> fastcars = (from fcar in mycars where fcar. speed> 55 select fcar ). tolist <car> (); foreach (car c in fastcars) console. writeline (C. petname); // Nongeneric // non generic collection of car objects arraylist arcars = new arraylist {new car {color = "Silver", make = "BMW ", petname = "Henry", speed = 100}, new car {color = "Tan", make = "BMW", petname = "Daisy", speed = 90 }, new car {color = "black", make = "VW", petname = "Mary", speed = 55}, new car {color = "Rust ", make = "Yugo", petname = "clunker", speed = 5}, new car {color = "white", make = "Ford", petname = "melvin ", speed = 43 }}; // convert non generic car object collection to enumerable // ienumerable <car> mycars = arcars. oftype <car> (); // list <car> fastcars = (from fcar in mycars where fcar. speed> 55 select fcar ). tolist <car> (); // foreach (car c in fastcars) // console. writeline (C. petname );