[Solved] What is LINQ in following code?

Your question show complete lack of effort to investigate the matter. LINQ = Language INtegrated Queries; It’s language construct that allows you to query objects / databases / other in a manner similar to SQL. Start by reading some guide like this 4 solved What is LINQ in following code?

[Solved] Calling a function and text box from a button

You probably don’t want to return an exception from that method. It could use a void return type instead. For example: private void button1_Click(object sender, EventArgs e) { Student student = new Student();//set up student obj… string city = “Foo”; searchCity(student, city); } public void searchCity(Student student, string searchCity) { //Do your search… //set the … Read more

[Solved] SQL query to linq to SQL query

Use OrderBy for the ordering, and First or possibly FirstOrDefault for the equivalent of TOP 1: var session = db.Sessions.OrderBy(x => x.StartTime).FirstOrDefault(); if (session != null) { // Use the session } else { // There weren’t any sessions } You could use a query expression for the first part, but it seems pretty pointless … Read more

[Solved] Why null is returned?

This shouldn’t be the case. from wp in context.WorkPanels select wp; is equivalent to context.WorkPanels.Select(wp => wp);. The MS implementations of Select (Enumerable.Select / Queryable.Select) never return null. There must be something else wrong somewhere else. 4 solved Why null is returned?

[Solved] Printing Month Name in Linq

Rather than using ToString, try string.Format. Something like: var query = (from e in Employees let month = e.BirthDate.GetValueOrDefault() let birthmonth = string.Format(“{0:MMMM}”, month) select birthmonth); query.Dump(); This seems to work from my local testing, although it is not included as part of the SQL query. 0 solved Printing Month Name in Linq