Table of Contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.EntityFrameworkCore; | |
| namespace NorthWindSqlLiteApp1.Classes.Extensions; // Change to match your project namespace | |
| public static class EntityExtensions | |
| { | |
| /// <summary> | |
| /// Retrieves a list of CLR types representing the entities defined in the model of the specified <see cref="DbContext"/>. | |
| /// </summary> | |
| /// <param name="context"> | |
| /// The <see cref="DbContext"/> instance from which to retrieve the entity types. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FileHelpers | |
| { | |
| public static (bool isFolder, bool success) IsFileOrFolder(string path) | |
| { | |
| try | |
| { | |
| var attr = File.GetAttributes(path); | |
| return attr.HasFlag(FileAttributes.Directory) ? (true, true)! : (false, true)!; | |
| } | |
| catch (FileNotFoundException) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class LogicalPatterns | |
| { | |
| public static string ClassifyTemperature(this double temp) => temp switch | |
| { | |
| < 0 => "Bitterly cold", | |
| >= 0 and < 20 => "Chilly", | |
| >= 20 and < 30 => "Comfortably warm", | |
| >= 30 and not 100 => "Uncomfortably hot", | |
| 100 => "At the boiling point", | |
| _ => "Dangerously extreme" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal partial class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var value = Prompts.GetDate(); | |
| Console.WriteLine(value.Year == 1 ? "Cancelled" : $"Selected date: {value:dd/MM/yyyy HH:mm}"); | |
| Console.ReadLine(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal partial class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| SwitchSamples.Greeting(); | |
| Console.WriteLine(); | |
| SwitchSamples.GradesTuple(); | |
| Console.WriteLine(); | |
| SwitchSamples.GroupBook(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| string userInput = Console.ReadLine(); | |
| Console.WriteLine(Convert.ToInt32(userInput)); | |
| Console.ReadLine(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text.Json; | |
| namespace WorkingWithArrays; | |
| internal class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Console.WriteLine("Press ENTER to exit"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static decimal[] GetDecimals() | |
| => | |
| [ | |
| 99.40m, 98.62m, 98.13m, 96.31m, 85.59m, 78.95m, 62.73m, 58.23m, 57.36m, 57.03m, | |
| 50.41m, 49.46m, 35.86m, 30.07m, 29.84m, 27.56m, 25.73m, 17.10m, 13.95m, 10.32m | |
| ]; | |
| public static void LambdaWhereLocalArray() | |
| { | |
| decimal[] values = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text.Json; | |
| namespace WorkingWithArrays.Classes; | |
| internal class MockedData | |
| { | |
| public static decimal[] GetDecimals() | |
| => | |
| [ | |
| 99.40m, 98.62m, 98.13m, 96.31m, 85.59m, 78.95m, 62.73m, 58.23m, 57.36m, 57.03m, |
NewerOlder