{"id":25631212,"url":"https://github.com/adi501/linq_interview_questions","last_synced_at":"2026-06-12T20:30:28.346Z","repository":{"id":277570424,"uuid":"932842192","full_name":"adi501/LINQ_Interview_Questions","owner":"adi501","description":"LINQ Interview Questions","archived":false,"fork":false,"pushed_at":"2025-02-14T16:29:35.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T17:27:32.838Z","etag":null,"topics":["interview","interview-questions","linq","linq-to-sql","sql"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adi501.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-14T16:11:01.000Z","updated_at":"2025-02-14T16:31:10.000Z","dependencies_parsed_at":"2025-02-14T17:28:04.196Z","dependency_job_id":"bbe2312f-63cd-463e-a74b-1f75f33857b4","html_url":"https://github.com/adi501/LINQ_Interview_Questions","commit_stats":null,"previous_names":["adi501/linq_interview_questions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adi501%2FLINQ_Interview_Questions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adi501%2FLINQ_Interview_Questions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adi501%2FLINQ_Interview_Questions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adi501%2FLINQ_Interview_Questions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adi501","download_url":"https://codeload.github.com/adi501/LINQ_Interview_Questions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240230801,"owners_count":19768726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interview","interview-questions","linq","linq-to-sql","sql"],"created_at":"2025-02-22T20:19:29.618Z","updated_at":"2026-06-12T20:30:27.911Z","avatar_url":"https://github.com/adi501.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Left Outer Join using LINQ using Query Syntax**\n\n![image](https://github.com/user-attachments/assets/69b0bcfd-2ce9-4363-9cb1-cf87c2891e9a)\n\n![image](https://github.com/user-attachments/assets/5c1fee3f-addc-466b-b7ea-a1af672d2dbb)\n\n```\n//Performing Left Outer Join using LINQ using Query Syntax\n//Left Data Source: tbl_Courses\n//Right Data Source: tbl_Students\n//Note: Left and Right Data Source Matters\nvar data = from course in objDB.tbl_Courses  //Left Data Source\n           join student in objDB.tbl_Students  //Right Data Source\n           on course.Id equals student.Course_Id //Inner Join Condition\n           into stude //Performing LINQ Group Join\n           from stu in stude.DefaultIfEmpty() //Performing Left Outer Join\n           select new { stu.Name, course_Name = course.Name }; //Projecting the Result to Anonymous Type\n\nforeach (var d in data)\n{\n    Console.WriteLine(d.Name+\"---\"+d.course_Name);\n\n}\nConsole.ReadLine();\n```\n\n![image](https://github.com/user-attachments/assets/21b9a8a5-5a64-4684-b090-29e9ec0d9459)\n\n----------------------------------------------------------------------------------------------------------------------------------\n\n**Find Even Numbers given List using LINQ**\n\n```\nList\u003cint\u003e numbers=new List\u003cint\u003e() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n\n//Method 1 : find Even Numbers from List\nvar evenNumbers = from num in numbers\n                  where num % 2 == 0\n                  select num;\n\n//Method 2 : find Even Numbers from List\nvar evenNumbers2 = numbers.FindAll(numbers =\u003e numbers % 2 == 0);\n\n\n//Method 3 : find Even Numbers from List\nvar evenNumbers3 = numbers.Where(numbers =\u003e numbers % 2 == 0);\nforeach(var num in evenNumbers3)\n{\n    Console.WriteLine(num);  //O/P : 2,4,6,8,10\n}\nConsole.ReadLine();\n```\n---------------------------------------------------------------------------------------------------------------------------------\n**Group By in LINQ**\n```\nList\u003cEmployee\u003e _employees = new List\u003cEmployee\u003e\n{\n    new Employee { Id = 1, Name = \"A\", Department = \"HR\", Salary = 10000 },\n    new Employee { Id = 2, Name = \"B\", Department = \"IT\", Salary = 15000 },\n    new Employee { Id = 3, Name = \"C\", Department = \"IT\", Salary = 12000 },\n    new Employee { Id = 4, Name = \"D\", Department = \"HR\", Salary = 11000 },\n    new Employee    { Id = 5, Name = \"E\", Department = \"HR\", Salary = 9000 },\n    new     Employee { Id = 6, Name = \"F\", Department = \"IT\", Salary = 13000 }\n\n};\n//Method1: Group By Department and find Max Salary and Total Salary\nvar groupData1 = from emp in _employees\n                 group emp by emp.Department into egroup\n                 select new\n                 {\n                     Department = egroup.Key,\n                     //Employees = egroup,\n                     MaxSal = egroup.Max(e =\u003e e.Salary),\n                     TotalSal = egroup.Sum(e =\u003e e.Salary)\n                 };\n//Method2: Group By Department and find Max Salary and Total Salary\nvar groupData2 = _employees.GroupBy(e =\u003e e.Department)\n    .Select(g =\u003e new { Department = g.Key, MaxSal = g.Max(e =\u003e e.Salary), TotalSal = g.Sum(e =\u003e e.Salary) });\nforeach (var d in groupData2)\n{\n    Console.WriteLine(d.Department + \" \" + d.MaxSal + \" \" + d.TotalSal);\n}\nConsole.ReadLine();\n\npublic class Employee\n{\n    public int Id { get; set; }\n    public string Name { get; set; }\n    public string Department { get; set; }\n    public int Salary { get; set; }\n}\n```\n---------------------------------------------------------------------------------------------------------------------------------\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadi501%2Flinq_interview_questions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadi501%2Flinq_interview_questions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadi501%2Flinq_interview_questions/lists"}