Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
w
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class ClientVendor { public int VendorCompanyId{get;set;} public int ClientCompanyId{get;set;} } public class Employee { public int CompanyId{get;set;} public int Id{get;set;} } public class Program { public static void Main(string[] args) { var employeeIds = new int[]{2,9}; var vendorCompanyId = 2; var ClientVendors = new List<ClientVendor>{ new ClientVendor{ VendorCompanyId =2, ClientCompanyId =1 } }; var Employees = new List<Employee>{ new Employee{ CompanyId =1, Id =2 }, new Employee{ CompanyId =1, Id =10 }, new Employee{ CompanyId =1, Id =23 }, new Employee{ CompanyId =2, Id =9 } }; var clientEmployeeQuery = from clientVenor in ClientVendors .Where(item => item.VendorCompanyId == vendorCompanyId) join employee in Employees on clientVenor.ClientCompanyId equals employee.CompanyId into employeeJoin from employee in employeeJoin select employee; var vendorEmployeeQuery = Employees .Where(item => item.CompanyId == vendorCompanyId); clientEmployeeQuery .ToList() .ForEach(item =>Console.WriteLine(item.Id)); Console.WriteLine("-----------------------------------"); clientEmployeeQuery .Union(vendorEmployeeQuery) .ToList() .ForEach(item =>Console.WriteLine(item.Id)); Console.WriteLine("-----------------------------------"); Console.WriteLine( clientEmployeeQuery .Union(vendorEmployeeQuery) .All(item => employeeIds.Contains(item.Id))); Console.WriteLine("-----------------------------------"); Console.WriteLine( clientEmployeeQuery .Union(vendorEmployeeQuery) .Any(item => !employeeIds.Contains(item.Id))); } } }
run
|
edit
|
history
|
help
0
Bubble Sort
test
Bitwise Shifting for Strings
Strings in C# with some properties examples
Punnet Square Generator
count the occurrence of each distinct item in the array - Seeni
Static 2
xpath select element code
and
12