├── .gitignore ├── LICENSE ├── LINQTut06.Chunck ├── LINQTut06.Chunck.csproj └── Program.cs ├── LINQTut06.Pagination ├── Extensions.cs ├── LINQTut06.Pagination.csproj └── Program.cs ├── LINQTut06.Shared ├── Employee.cs ├── ExtensionFunctional.cs ├── LINQTut06.Shared.csproj └── Repository.cs ├── LINQTut06.Skip ├── LINQTut06.Skip.csproj └── Program.cs ├── LINQTut06.Take ├── LINQTut06.Take.csproj └── Program.cs ├── LINQTut06.sln └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # Tye 66 | .tye/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.vspscc 97 | *.vssscc 98 | .builds 99 | *.pidb 100 | *.svclog 101 | *.scc 102 | 103 | # Chutzpah Test files 104 | _Chutzpah* 105 | 106 | # Visual C++ cache files 107 | ipch/ 108 | *.aps 109 | *.ncb 110 | *.opendb 111 | *.opensdf 112 | *.sdf 113 | *.cachefile 114 | *.VC.db 115 | *.VC.VC.opendb 116 | 117 | # Visual Studio profiler 118 | *.psess 119 | *.vsp 120 | *.vspx 121 | *.sap 122 | 123 | # Visual Studio Trace Files 124 | *.e2e 125 | 126 | # TFS 2012 Local Workspace 127 | $tf/ 128 | 129 | # Guidance Automation Toolkit 130 | *.gpState 131 | 132 | # ReSharper is a .NET coding add-in 133 | _ReSharper*/ 134 | *.[Rr]e[Ss]harper 135 | *.DotSettings.user 136 | 137 | # TeamCity is a build add-in 138 | _TeamCity* 139 | 140 | # DotCover is a Code Coverage Tool 141 | *.dotCover 142 | 143 | # AxoCover is a Code Coverage Tool 144 | .axoCover/* 145 | !.axoCover/settings.json 146 | 147 | # Coverlet is a free, cross platform Code Coverage Tool 148 | coverage*.json 149 | coverage*.xml 150 | coverage*.info 151 | 152 | # Visual Studio code coverage results 153 | *.coverage 154 | *.coveragexml 155 | 156 | # NCrunch 157 | _NCrunch_* 158 | .*crunch*.local.xml 159 | nCrunchTemp_* 160 | 161 | # MightyMoose 162 | *.mm.* 163 | AutoTest.Net/ 164 | 165 | # Web workbench (sass) 166 | .sass-cache/ 167 | 168 | # Installshield output folder 169 | [Ee]xpress/ 170 | 171 | # DocProject is a documentation generator add-in 172 | DocProject/buildhelp/ 173 | DocProject/Help/*.HxT 174 | DocProject/Help/*.HxC 175 | DocProject/Help/*.hhc 176 | DocProject/Help/*.hhk 177 | DocProject/Help/*.hhp 178 | DocProject/Help/Html2 179 | DocProject/Help/html 180 | 181 | # Click-Once directory 182 | publish/ 183 | 184 | # Publish Web Output 185 | *.[Pp]ublish.xml 186 | *.azurePubxml 187 | # Note: Comment the next line if you want to checkin your web deploy settings, 188 | # but database connection strings (with potential passwords) will be unencrypted 189 | *.pubxml 190 | *.publishproj 191 | 192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 193 | # checkin your Azure Web App publish settings, but sensitive information contained 194 | # in these scripts will be unencrypted 195 | PublishScripts/ 196 | 197 | # NuGet Packages 198 | *.nupkg 199 | # NuGet Symbol Packages 200 | *.snupkg 201 | # The packages folder can be ignored because of Package Restore 202 | **/[Pp]ackages/* 203 | # except build/, which is used as an MSBuild target. 204 | !**/[Pp]ackages/build/ 205 | # Uncomment if necessary however generally it will be regenerated when needed 206 | #!**/[Pp]ackages/repositories.config 207 | # NuGet v3's project.json files produces more ignorable files 208 | *.nuget.props 209 | *.nuget.targets 210 | 211 | # Microsoft Azure Build Output 212 | csx/ 213 | *.build.csdef 214 | 215 | # Microsoft Azure Emulator 216 | ecf/ 217 | rcf/ 218 | 219 | # Windows Store app package directories and files 220 | AppPackages/ 221 | BundleArtifacts/ 222 | Package.StoreAssociation.xml 223 | _pkginfo.txt 224 | *.appx 225 | *.appxbundle 226 | *.appxupload 227 | 228 | # Visual Studio cache files 229 | # files ending in .cache can be ignored 230 | *.[Cc]ache 231 | # but keep track of directories ending in .cache 232 | !?*.[Cc]ache/ 233 | 234 | # Others 235 | ClientBin/ 236 | ~$* 237 | *~ 238 | *.dbmdl 239 | *.dbproj.schemaview 240 | *.jfm 241 | *.pfx 242 | *.publishsettings 243 | orleans.codegen.cs 244 | 245 | # Including strong name files can present a security risk 246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 247 | #*.snk 248 | 249 | # Since there are multiple workflows, uncomment next line to ignore bower_components 250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 251 | #bower_components/ 252 | 253 | # RIA/Silverlight projects 254 | Generated_Code/ 255 | 256 | # Backup & report files from converting an old project file 257 | # to a newer Visual Studio version. Backup files are not needed, 258 | # because we have git ;-) 259 | _UpgradeReport_Files/ 260 | Backup*/ 261 | UpgradeLog*.XML 262 | UpgradeLog*.htm 263 | ServiceFabricBackup/ 264 | *.rptproj.bak 265 | 266 | # SQL Server files 267 | *.mdf 268 | *.ldf 269 | *.ndf 270 | 271 | # Business Intelligence projects 272 | *.rdl.data 273 | *.bim.layout 274 | *.bim_*.settings 275 | *.rptproj.rsuser 276 | *- [Bb]ackup.rdl 277 | *- [Bb]ackup ([0-9]).rdl 278 | *- [Bb]ackup ([0-9][0-9]).rdl 279 | 280 | # Microsoft Fakes 281 | FakesAssemblies/ 282 | 283 | # GhostDoc plugin setting file 284 | *.GhostDoc.xml 285 | 286 | # Node.js Tools for Visual Studio 287 | .ntvs_analysis.dat 288 | node_modules/ 289 | 290 | # Visual Studio 6 build log 291 | *.plg 292 | 293 | # Visual Studio 6 workspace options file 294 | *.opt 295 | 296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 297 | *.vbw 298 | 299 | # Visual Studio LightSwitch build output 300 | **/*.HTMLClient/GeneratedArtifacts 301 | **/*.DesktopClient/GeneratedArtifacts 302 | **/*.DesktopClient/ModelManifest.xml 303 | **/*.Server/GeneratedArtifacts 304 | **/*.Server/ModelManifest.xml 305 | _Pvt_Extensions 306 | 307 | # Paket dependency manager 308 | .paket/paket.exe 309 | paket-files/ 310 | 311 | # FAKE - F# Make 312 | .fake/ 313 | 314 | # CodeRush personal settings 315 | .cr/personal 316 | 317 | # Python Tools for Visual Studio (PTVS) 318 | __pycache__/ 319 | *.pyc 320 | 321 | # Cake - Uncomment if you are using it 322 | # tools/** 323 | # !tools/packages.config 324 | 325 | # Tabs Studio 326 | *.tss 327 | 328 | # Telerik's JustMock configuration file 329 | *.jmconfig 330 | 331 | # BizTalk build output 332 | *.btp.cs 333 | *.btm.cs 334 | *.odx.cs 335 | *.xsd.cs 336 | 337 | # OpenCover UI analysis results 338 | OpenCover/ 339 | 340 | # Azure Stream Analytics local run output 341 | ASALocalRun/ 342 | 343 | # MSBuild Binary and Structured Log 344 | *.binlog 345 | 346 | # NVidia Nsight GPU debugger configuration file 347 | *.nvuser 348 | 349 | # MFractors (Xamarin productivity tool) working folder 350 | .mfractor/ 351 | 352 | # Local History for Visual Studio 353 | .localhistory/ 354 | 355 | # BeatPulse healthcheck temp database 356 | healthchecksdb 357 | 358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 359 | MigrationBackup/ 360 | 361 | # Ionide (cross platform F# VS Code tools) working folder 362 | .ionide/ 363 | 364 | # Fody - auto-generated XML schema 365 | FodyWeavers.xsd 366 | 367 | ## 368 | ## Visual studio for Mac 369 | ## 370 | 371 | 372 | # globs 373 | Makefile.in 374 | *.userprefs 375 | *.usertasks 376 | config.make 377 | config.status 378 | aclocal.m4 379 | install-sh 380 | autom4te.cache/ 381 | *.tar.gz 382 | tarballs/ 383 | test-results/ 384 | 385 | # Mac bundle stuff 386 | *.dmg 387 | *.app 388 | 389 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 390 | # General 391 | .DS_Store 392 | .AppleDouble 393 | .LSOverride 394 | 395 | # Icon must end with two \r 396 | Icon 397 | 398 | 399 | # Thumbnails 400 | ._* 401 | 402 | # Files that might appear in the root of a volume 403 | .DocumentRevisions-V100 404 | .fseventsd 405 | .Spotlight-V100 406 | .TemporaryItems 407 | .Trashes 408 | .VolumeIcon.icns 409 | .com.apple.timemachine.donotpresent 410 | 411 | # Directories potentially created on remote AFP share 412 | .AppleDB 413 | .AppleDesktop 414 | Network Trash Folder 415 | Temporary Items 416 | .apdisk 417 | 418 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 419 | # Windows thumbnail cache files 420 | Thumbs.db 421 | ehthumbs.db 422 | ehthumbs_vista.db 423 | 424 | # Dump file 425 | *.stackdump 426 | 427 | # Folder config file 428 | [Dd]esktop.ini 429 | 430 | # Recycle Bin used on file shares 431 | $RECYCLE.BIN/ 432 | 433 | # Windows Installer files 434 | *.cab 435 | *.msi 436 | *.msix 437 | *.msm 438 | *.msp 439 | 440 | # Windows shortcuts 441 | *.lnk 442 | 443 | # JetBrains Rider 444 | .idea/ 445 | *.sln.iml 446 | 447 | ## 448 | ## Visual Studio Code 449 | ## 450 | .vscode/* 451 | !.vscode/settings.json 452 | !.vscode/tasks.json 453 | !.vscode/launch.json 454 | !.vscode/extensions.json 455 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Metigator 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LINQTut06.Chunck/LINQTut06.Chunck.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /LINQTut06.Chunck/Program.cs: -------------------------------------------------------------------------------- 1 | using LINQTut06.Shared; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace LINQTut06.Chunck 6 | { 7 | internal class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | var emps = Repository.LoadEmployees(); 12 | 13 | var chuncks = emps.Chunk(10).ToList(); 14 | 15 | for (int i = 0; i < chuncks.Count; i++) 16 | { 17 | chuncks[i].Print($"Chunk #{i + 1}"); 18 | } 19 | 20 | Console.ReadKey(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LINQTut06.Pagination/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace LINQTut06.Pagination 8 | { 9 | public static class Extensions 10 | { 11 | public static IEnumerable Paginate(this IEnumerable source, 12 | int page = 1, int size = 10) where T : class 13 | { 14 | if (page <= 0) 15 | { 16 | page = 1; 17 | } 18 | 19 | if (size <= 0) 20 | { 21 | size = 10; 22 | } 23 | 24 | var total = source.Count(); 25 | 26 | var pages = (int)Math.Ceiling((decimal)total / size); 27 | 28 | var result = source.Skip((page - 1) * size).Take(size); 29 | 30 | return result; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LINQTut06.Pagination/LINQTut06.Pagination.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /LINQTut06.Pagination/Program.cs: -------------------------------------------------------------------------------- 1 | using LINQTut06.Shared; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace LINQTut06.Pagination 6 | { 7 | internal class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | var page = 1; 12 | var size = 10; 13 | 14 | Console.WriteLine("result per page:"); 15 | if(int.TryParse(Console.ReadLine(), out int resultPerPage)) 16 | { 17 | size = resultPerPage; 18 | } 19 | Console.WriteLine("page No.:"); 20 | if (int.TryParse(Console.ReadLine(), out int pageNo)) 21 | { 22 | page = pageNo; 23 | } 24 | 25 | var emps = Repository.LoadEmployees(); 26 | 27 | var result = emps.Paginate(page, size); 28 | 29 | var resultCount = result.Count(); 30 | 31 | var startRecord = ((page - 1) * size) + 1; 32 | 33 | var endRecord = 34 | resultCount < size 35 | ? startRecord + resultCount - 1 36 | : size * (page - 1) + size; 37 | 38 | result.Print($"showing employees {startRecord} - {endRecord}"); 39 | 40 | Console.ReadKey(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /LINQTut06.Shared/Employee.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace LINQTut06.Shared 7 | { 8 | public class Employee 9 | { 10 | public int Index { get; set; } 11 | public string EmployeeNo { get; set; } 12 | 13 | public string Name { get; set; } 14 | 15 | public string Email { get; set; } 16 | public decimal Salary { get; set; } 17 | 18 | public List Skills { get; set; } = new List(); 19 | 20 | 21 | public override string ToString() 22 | { 23 | 24 | return 25 | $"" + 26 | $" {Index.ToString().PadLeft(3, '0')}\t" + 27 | $" {EmployeeNo.PadRight(13, ' ')}\t" + 28 | $" {Name.PadRight(20, ' ')}\t" + 29 | $" {Email.PadRight(32, ' ')}\t" + 30 | $" {String.Format("{0:C0}", Salary)}"; 31 | 32 | } 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /LINQTut06.Shared/ExtensionFunctional.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | namespace LINQTut06.Shared 4 | { 5 | public static class ExtensionFunctional 6 | { 7 | 8 | public static IEnumerable Filter 9 | (this IEnumerable source, Func predicate) 10 | { 11 | 12 | foreach (var employee in source) 13 | { 14 | if (predicate(employee)) 15 | { 16 | yield return employee; 17 | } 18 | } 19 | } 20 | 21 | public static void Print(this IEnumerable source, string title) 22 | { 23 | if (source == null) 24 | return; 25 | Console.WriteLine(); 26 | Console.WriteLine("┌───────────────────────────────────────────────────────┐"); 27 | Console.WriteLine($"│ {title.PadRight(52, ' ')}│"); 28 | Console.WriteLine("└───────────────────────────────────────────────────────┘"); 29 | Console.WriteLine(); 30 | foreach (var item in source) 31 | { 32 | if (typeof(T).IsValueType) 33 | Console.Write($" {item} "); // 1, 2, 3 34 | else 35 | Console.WriteLine(item); 36 | } 37 | 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LINQTut06.Shared/LINQTut06.Shared.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LINQTut06.Shared/Repository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace LINQTut06.Shared 6 | { 7 | public static class Repository 8 | { 9 | 10 | public static IEnumerable LoadEmployees() 11 | { 12 | return new List 13 | { 14 | new Employee 15 | { 16 | Index = 1, 17 | EmployeeNo = "2017-FI-8516", 18 | Name = "Cochran Cole", 19 | Email = "Cole.Cochran@example.com", 20 | Salary = 103200, 21 | Skills = new() {"Javascript" , "NodeJS" } 22 | }, 23 | new Employee 24 | { 25 | Index = 2, 26 | EmployeeNo = "2018-FI-4815", 27 | Name = "Jaclyn Wolfe", 28 | Email = "Wolfe.Jaclyn@example.com", 29 | Salary = 192400, 30 | Skills = new() {"C++" , "Javascript" , "Oracle" } 31 | }, 32 | new Employee 33 | { 34 | Index = 3, 35 | EmployeeNo = "2016-IT-1329", 36 | Name = "Warner Jones", 37 | Email = "Jones.Warner@example.com", 38 | Salary = 172800, 39 | Skills = new() {"NodeJS" , "C++" } 40 | }, 41 | new Employee 42 | { 43 | Index = 4, 44 | EmployeeNo = "2016-FI-8336", 45 | Name = "Hester Evans", 46 | Email = "Evans.Hester@example.com", 47 | Salary = 155500, 48 | Skills = new() {"C++" , "SQL Server" } 49 | }, 50 | new Employee 51 | { 52 | Index = 5, 53 | EmployeeNo = "2014-IT-3129", 54 | Name = "Wallace Buck", 55 | Email = "Buck.Wallace@example.com", 56 | Salary = 315800, 57 | Skills = new() {"HTML" , "ASP.NET" , "NodeJS" } 58 | }, 59 | new Employee 60 | { 61 | Index = 6, 62 | EmployeeNo = "2020-IT-6518", 63 | Name = "Acevedo Wall", 64 | Email = "Wall.Acevedo@example.com", 65 | Salary = 343700, 66 | Skills = new() {"Oracle" , "Javascript" , "C++" , "NodeJS" } 67 | }, 68 | new Employee 69 | { 70 | Index = 7, 71 | EmployeeNo = "2021-IT-8443", 72 | Name = "Jacqueline Pickett", 73 | Email = "Pickett.Jacqueline@example.com", 74 | Salary = 370000, 75 | Skills = new() {"CSS" , "NodeJS" , "HTML" } 76 | }, 77 | new Employee 78 | { 79 | Index = 8, 80 | EmployeeNo = "2017-HR-1202", 81 | Name = "Oconnor Espinoza", 82 | Email = "Espinoza.Oconnor@example.com", 83 | Salary = 155600, 84 | Skills = new() {"Oracle" , "C++" , "SQL Server" , "HTML" , "CSS" } 85 | }, 86 | new Employee 87 | { 88 | Index = 9, 89 | EmployeeNo = "2020-AC-1097", 90 | Name = "Allie Elliott", 91 | Email = "Elliott.Allie@example.com", 92 | Salary = 315400, 93 | Skills = new() {"C++" } 94 | }, 95 | new Employee 96 | { 97 | Index = 10, 98 | EmployeeNo = "2016-HR-3735", 99 | Name = "Elva Decker", 100 | Email = "Decker.Elva@example.com", 101 | Salary = 345900, 102 | Skills = new() {"CSS" } 103 | }, 104 | new Employee 105 | { 106 | Index = 11, 107 | EmployeeNo = "2020-HR-1618", 108 | Name = "Hayes Beasley", 109 | Email = "Beasley.Hayes@example.com", 110 | Salary = 372700, 111 | Skills = new() {"Javascript" , "C++" } 112 | }, 113 | new Employee 114 | { 115 | Index = 12, 116 | EmployeeNo = "2015-FI-4476", 117 | Name = "Florine Cervantes", 118 | Email = "Cervantes.Florine@example.com", 119 | Salary = 338700, 120 | Skills = new() {"NodeJS" , "C++" , "CSS" , "HTML" , "SQL Server" } 121 | }, 122 | new Employee 123 | { 124 | Index = 13, 125 | EmployeeNo = "2017-AC-6435", 126 | Name = "Bullock Carney", 127 | Email = "Carney.Bullock@example.com", 128 | Salary = 214400, 129 | Skills = new() {"ASP.NET" , "CSS" , "HTML" } 130 | }, 131 | new Employee 132 | { 133 | Index = 14, 134 | EmployeeNo = "2021-FI-5719", 135 | Name = "Carroll Cantu", 136 | Email = "Cantu.Carroll@example.com", 137 | Salary = 343200, 138 | Skills = new() {"NodeJS" , "C++" , "Oracle" } 139 | }, 140 | new Employee 141 | { 142 | Index = 15, 143 | EmployeeNo = "2019-IT-9095", 144 | Name = "Debra Hogan", 145 | Email = "Hogan.Debra@example.com", 146 | Salary = 249100, 147 | Skills = new() {"CSS" , "C#" , "C++" , "NodeJS" , "SQL Server" } 148 | }, 149 | new Employee 150 | { 151 | Index = 16, 152 | EmployeeNo = "2019-IT-5252", 153 | Name = "Winnie Mccall", 154 | Email = "Mccall.Winnie@example.com", 155 | Salary = 287300, 156 | Skills = new() {"NodeJS" } 157 | }, 158 | new Employee 159 | { 160 | Index = 17, 161 | EmployeeNo = "2015-IT-3783", 162 | Name = "Manuela Berger", 163 | Email = "Berger.Manuela@example.com", 164 | Salary = 172500, 165 | Skills = new() {"ASP.NET" , "Javascript" , "SQL Server" } 166 | }, 167 | new Employee 168 | { 169 | Index = 18, 170 | EmployeeNo = "2017-IT-2332", 171 | Name = "Lakeisha Lowe", 172 | Email = "Lowe.Lakeisha@example.com", 173 | Salary = 314300, 174 | Skills = new() {"ASP.NET" , "Oracle" , "C#" , "CSS" , "HTML" } 175 | }, 176 | new Employee 177 | { 178 | Index = 19, 179 | EmployeeNo = "2016-FI-4247", 180 | Name = "Stewart Lott", 181 | Email = "Lott.Stewart@example.com", 182 | Salary = 146600, 183 | Skills = new() {"Javascript" } 184 | }, 185 | new Employee 186 | { 187 | Index = 20, 188 | EmployeeNo = "2014-IT-4977", 189 | Name = "Stafford Peck", 190 | Email = "Peck.Stafford@example.com", 191 | Salary = 320700, 192 | Skills = new() {"Javascript" , "CSS" , "HTML" , "SQL Server" } 193 | }, 194 | new Employee 195 | { 196 | Index = 21, 197 | EmployeeNo = "2020-HR-9364", 198 | Name = "Barron Bird", 199 | Email = "Bird.Barron@example.com", 200 | Salary = 151200, 201 | Skills = new() {"SQL Server" , "ASP.NET" } 202 | }, 203 | new Employee 204 | { 205 | Index = 22, 206 | EmployeeNo = "2015-IT-3776", 207 | Name = "Nona Brooks", 208 | Email = "Brooks.Nona@example.com", 209 | Salary = 136500, 210 | Skills = new() {"Oracle" , "NodeJS" , "Javascript" , "CSS" } 211 | }, 212 | new Employee 213 | { 214 | Index = 23, 215 | EmployeeNo = "2014-IT-5660", 216 | Name = "Clara Reeves", 217 | Email = "Reeves.Clara@example.com", 218 | Salary = 245800, 219 | Skills = new() {"ASP.NET" , "HTML" , "C#" } 220 | }, 221 | new Employee 222 | { 223 | Index = 24, 224 | EmployeeNo = "2018-IT-3051", 225 | Name = "Karin Blanchard", 226 | Email = "Blanchard.Karin@example.com", 227 | Salary = 341200, 228 | Skills = new() {"Oracle" , "Javascript" , "CSS" , "ASP.NET" , "HTML" } 229 | }, 230 | new Employee 231 | { 232 | Index = 25, 233 | EmployeeNo = "2019-AC-8619", 234 | Name = "Burris Morgan", 235 | Email = "Morgan.Burris@example.com", 236 | Salary = 360300, 237 | Skills = new() {"HTML" , "CSS" , "Javascript" } 238 | }, 239 | new Employee 240 | { 241 | Index = 26, 242 | EmployeeNo = "2021-IT-7779", 243 | Name = "Owen Cortez", 244 | Email = "Cortez.Owen@example.com", 245 | Salary = 193700, 246 | Skills = new() {"Oracle" , "NodeJS" , "C++" } 247 | }, 248 | new Employee 249 | { 250 | Index = 27, 251 | EmployeeNo = "2016-AC-6545", 252 | Name = "Letha Finch", 253 | Email = "Finch.Letha@example.com", 254 | Salary = 357200, 255 | Skills = new() {"NodeJS" , "Javascript" , "CSS" , "C#" , "HTML" } 256 | }, 257 | new Employee 258 | { 259 | Index = 28, 260 | EmployeeNo = "2016-AC-4450", 261 | Name = "Sondra Rojas", 262 | Email = "Rojas.Sondra@example.com", 263 | Salary = 309700, 264 | Skills = new() {"CSS" } 265 | }, 266 | new Employee 267 | { 268 | Index = 29, 269 | EmployeeNo = "2020-HR-5396", 270 | Name = "Hoover Cook", 271 | Email = "Cook.Hoover@example.com", 272 | Salary = 282200, 273 | Skills = new() {"C++" , "C#" , "Javascript" } 274 | }, 275 | new Employee 276 | { 277 | Index = 30, 278 | EmployeeNo = "2021-AC-7859", 279 | Name = "Wanda Bender", 280 | Email = "Bender.Wanda@example.com", 281 | Salary = 294200, 282 | Skills = new() {"ASP.NET" , "SQL Server" } 283 | }, 284 | new Employee 285 | { 286 | Index = 31, 287 | EmployeeNo = "2020-AC-4905", 288 | Name = "Sanford Craig", 289 | Email = "Craig.Sanford@example.com", 290 | Salary = 278200, 291 | Skills = new() {"C++" , "ASP.NET" } 292 | }, 293 | new Employee 294 | { 295 | Index = 32, 296 | EmployeeNo = "2021-FI-4586", 297 | Name = "Christy Middleton", 298 | Email = "Middleton.Christy@example.com", 299 | Salary = 377400, 300 | Skills = new() {"Javascript" , "SQL Server" , "Oracle" } 301 | }, 302 | new Employee 303 | { 304 | Index = 33, 305 | EmployeeNo = "2019-HR-4126", 306 | Name = "Day Brady", 307 | Email = "Brady.Day@example.com", 308 | Salary = 142600, 309 | Skills = new() {"C#" } 310 | }, 311 | new Employee 312 | { 313 | Index = 34, 314 | EmployeeNo = "2014-FI-5651", 315 | Name = "Powers Beard", 316 | Email = "Beard.Powers@example.com", 317 | Salary = 224000, 318 | Skills = new() {"CSS" , "Oracle" } 319 | }, 320 | new Employee 321 | { 322 | Index = 35, 323 | EmployeeNo = "2017-FI-3279", 324 | Name = "Arline Pratt", 325 | Email = "Pratt.Arline@example.com", 326 | Salary = 360300, 327 | Skills = new() {"Oracle" } 328 | }, 329 | new Employee 330 | { 331 | Index = 36, 332 | EmployeeNo = "2017-AC-7841", 333 | Name = "Sharpe Cardenas", 334 | Email = "Cardenas.Sharpe@example.com", 335 | Salary = 266100, 336 | Skills = new() {"HTML" , "C++" , "NodeJS" , "CSS" , "C#" } 337 | }, 338 | new Employee 339 | { 340 | Index = 37, 341 | EmployeeNo = "2020-AC-4489", 342 | Name = "Madeleine Stanton", 343 | Email = "Stanton.Madeleine@example.com", 344 | Salary = 198300, 345 | Skills = new() {"HTML" , "Javascript" , "SQL Server" } 346 | }, 347 | new Employee 348 | { 349 | Index = 38, 350 | EmployeeNo = "2014-FI-5748", 351 | Name = "Spears Noble", 352 | Email = "Noble.Spears@example.com", 353 | Salary = 176300, 354 | Skills = new() {"ASP.NET" , "C++" } 355 | }, 356 | new Employee 357 | { 358 | Index = 39, 359 | EmployeeNo = "2021-IT-6984", 360 | Name = "Gonzalez Gilliam", 361 | Email = "Gilliam.Gonzalez@example.com", 362 | Salary = 394300, 363 | Skills = new() {"SQL Server" , "C++" , "CSS" , "C#" } 364 | }, 365 | new Employee 366 | { 367 | Index = 40, 368 | EmployeeNo = "2018-FI-4000", 369 | Name = "Abigail Bradford", 370 | Email = "Bradford.Abigail@example.com", 371 | Salary = 296100, 372 | Skills = new() {"C#" , "ASP.NET" , "SQL Server" , "C++" } 373 | }, 374 | new Employee 375 | { 376 | Index = 41, 377 | EmployeeNo = "2020-IT-3146", 378 | Name = "Ashlee Farmer", 379 | Email = "Farmer.Ashlee@example.com", 380 | Salary = 125300, 381 | Skills = new() {"ASP.NET" , "C++" } 382 | }, 383 | new Employee 384 | { 385 | Index = 42, 386 | EmployeeNo = "2014-IT-7834", 387 | Name = "Glover Lloyd", 388 | Email = "Lloyd.Glover@example.com", 389 | Salary = 123000, 390 | Skills = new() {"HTML" , "Oracle" } 391 | }, 392 | new Employee 393 | { 394 | Index = 43, 395 | EmployeeNo = "2018-IT-9589", 396 | Name = "Cleo Mays", 397 | Email = "Mays.Cleo@example.com", 398 | Salary = 214900, 399 | Skills = new() {"HTML" , "CSS" } 400 | }, 401 | new Employee 402 | { 403 | Index = 44, 404 | EmployeeNo = "2021-IT-4204", 405 | Name = "Patrice House", 406 | Email = "House.Patrice@example.com", 407 | Salary = 124500, 408 | Skills = new() {"C++" } 409 | }, 410 | new Employee 411 | { 412 | Index = 45, 413 | EmployeeNo = "2015-AC-3311", 414 | Name = "Atkins Shannon", 415 | Email = "Shannon.Atkins@example.com", 416 | Salary = 136600, 417 | Skills = new() {"SQL Server" , "HTML" , "Oracle" } 418 | }, 419 | new Employee 420 | { 421 | Index = 46, 422 | EmployeeNo = "2016-AC-4280", 423 | Name = "Luisa Hopkins", 424 | Email = "Hopkins.Luisa@example.com", 425 | Salary = 192900, 426 | Skills = new() {"C++" , "ASP.NET" } 427 | }, 428 | new Employee 429 | { 430 | Index = 47, 431 | EmployeeNo = "2016-IT-6226", 432 | Name = "Kaufman Gross", 433 | Email = "Gross.Kaufman@example.com", 434 | Salary = 223600, 435 | Skills = new() {"C++" } 436 | }, 437 | new Employee 438 | { 439 | Index = 48, 440 | EmployeeNo = "2014-HR-6441", 441 | Name = "William Clay", 442 | Email = "Clay.William@example.com", 443 | Salary = 237500, 444 | Skills = new() {"Oracle" , "C++" , "Javascript" } 445 | }, 446 | new Employee 447 | { 448 | Index = 49, 449 | EmployeeNo = "2014-IT-9876", 450 | Name = "Alison Kirby", 451 | Email = "Kirby.Alison@example.com", 452 | Salary = 354800, 453 | Skills = new() {"ASP.NET" } 454 | }, 455 | new Employee 456 | { 457 | Index = 50, 458 | EmployeeNo = "2014-AC-1273", 459 | Name = "Morrow Lynch", 460 | Email = "Lynch.Morrow@example.com", 461 | Salary = 281400, 462 | Skills = new() {"NodeJS" , "C++" } 463 | } 464 | }; 465 | } 466 | } 467 | } 468 | -------------------------------------------------------------------------------- /LINQTut06.Skip/LINQTut06.Skip.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /LINQTut06.Skip/Program.cs: -------------------------------------------------------------------------------- 1 | using LINQTut06.Shared; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace LINQTut06.Skip 6 | { 7 | internal class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | var emps = Repository.LoadEmployees(); 12 | 13 | var q1 = emps.Skip(10); 14 | 15 | q1.Print("Skip First 10 employees"); 16 | 17 | 18 | var q2 = emps.SkipWhile(x => x.Salary != 214400); 19 | q2.Print("skip while salary does not equal 214,400"); 20 | 21 | var q3 = emps.SkipLast(10); 22 | q3.Print("skip last 10 elements"); 23 | Console.ReadKey(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LINQTut06.Take/LINQTut06.Take.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /LINQTut06.Take/Program.cs: -------------------------------------------------------------------------------- 1 | using LINQTut06.Shared; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace LINQTut06.Take 6 | { 7 | internal class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | var emps = Repository.LoadEmployees(); 12 | 13 | var q1 = emps.Take(10); 14 | 15 | q1.Print("take First 10 employees"); 16 | 17 | 18 | var q2 = emps.TakeWhile(x => x.Salary != 214400); 19 | q2.Print("take while salary does not equal 214,400"); 20 | 21 | var q3 = emps.TakeLast(10); 22 | q3.Print("take last 10 elements"); 23 | 24 | Console.ReadKey(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LINQTut06.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32014.148 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINQTut06.Shared", "LINQTut06.Shared\LINQTut06.Shared.csproj", "{C4CB4749-B8AD-4E53-AAB0-3C89A2D9B8AB}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINQTut06.Chunck", "LINQTut06.Chunck\LINQTut06.Chunck.csproj", "{22F403CA-F00F-4413-B546-99C452322E75}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINQTut06.Take", "LINQTut06.Take\LINQTut06.Take.csproj", "{08BC34A6-73C0-452F-9429-079F8A55BE48}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINQTut06.Skip", "LINQTut06.Skip\LINQTut06.Skip.csproj", "{EEF9DBA7-7816-4B70-9069-55D70F8FFCBD}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINQTut06.Pagination", "LINQTut06.Pagination\LINQTut06.Pagination.csproj", "{A962522B-1B14-42C7-BF25-681387FB9154}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {C4CB4749-B8AD-4E53-AAB0-3C89A2D9B8AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {C4CB4749-B8AD-4E53-AAB0-3C89A2D9B8AB}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {C4CB4749-B8AD-4E53-AAB0-3C89A2D9B8AB}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {C4CB4749-B8AD-4E53-AAB0-3C89A2D9B8AB}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {22F403CA-F00F-4413-B546-99C452322E75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {22F403CA-F00F-4413-B546-99C452322E75}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {22F403CA-F00F-4413-B546-99C452322E75}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {22F403CA-F00F-4413-B546-99C452322E75}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {08BC34A6-73C0-452F-9429-079F8A55BE48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {08BC34A6-73C0-452F-9429-079F8A55BE48}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {08BC34A6-73C0-452F-9429-079F8A55BE48}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {08BC34A6-73C0-452F-9429-079F8A55BE48}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {EEF9DBA7-7816-4B70-9069-55D70F8FFCBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {EEF9DBA7-7816-4B70-9069-55D70F8FFCBD}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {EEF9DBA7-7816-4B70-9069-55D70F8FFCBD}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {EEF9DBA7-7816-4B70-9069-55D70F8FFCBD}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {A962522B-1B14-42C7-BF25-681387FB9154}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {A962522B-1B14-42C7-BF25-681387FB9154}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {A962522B-1B14-42C7-BF25-681387FB9154}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {A962522B-1B14-42C7-BF25-681387FB9154}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityGlobals) = postSolution 47 | SolutionGuid = {E30FE6AD-A68B-44F7-90D3-D5D29E5925FC} 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Linq_Lesson_006 --------------------------------------------------------------------------------