توضیحاتی در مورد کتاب :
راهنمای قابل دسترس برای برنامه نویسان مبتدی تا متوسط برای مفاهیم، برنامه های کاربردی دنیای واقعی و آخرین ویژگی های C# 11 و .NET 7، همراه با تمرینات عملی با استفاده از Visual Studio 2022 و Visual Studio Code
ویژگی های کلیدی جدیدترین موارد اضافه شده به C# 11، کتابخانه های کلاس NET 7 و Entity Framework Core 7 ایجاد وب سایت ها و خدمات حرفه ای با ASP.NET Core 7 و Blazor اعتماد به نفس خود را با مثال های کد گام به گام و نکاتی برای بهترین شیوه ها ایجاد کنید
این آخرین نسخه راهنمای ما که برای تطبیق با جدیدترین ویژگی های C# 11 و .NET 7 به طور گسترده اصلاح شده است، به شما امکان می دهد با اطمینان در C# کدنویسی کنید.
شما برنامه نویسی شی گرا، توابع نوشتن، تست و اشکال زدایی، پیاده سازی رابط ها و کلاس های ارث بری را یاد خواهید گرفت. در مرحله بعد، API های NET را برای انجام وظایفی مانند مدیریت و جستجوی داده ها، کار با سیستم فایل و سریال سازی بر عهده خواهید گرفت. با پیشرفت، نمونههایی از پروژههای چند پلتفرمی را که میتوانید بسازید و اجرا کنید، مانند وبسایتها و خدمات با استفاده از ASP.NET Core، کاوش خواهید کرد.
به جای اینکه حواس شما را با کدهای رابط کاربری گرافیکی غیرضروری پرت کند، یازده فصل اول ساختارهای زبان C# و بسیاری از کتابخانه های دات نت را از طریق برنامه های کاربردی کنسول ساده به شما آموزش می دهد. در فصلهای بعدی، با تسلط بر اصول اولیه، وبسایتها، خدمات وب و برنامههای مرورگر را با استفاده از ASP.NET Core، الگوی Model-View-Controller (MVC) و Blazor میسازید.
C# 11 و .NET 7 - مبانی توسعه چند پلتفرمی مدرن به شما پایه ای محکم برای شروع ساختن برنامه ها و خدمات با اطمینان می دهد. در پایان این کتاب، میتوانید تجربههای وب غنی ایجاد کنید و درک کاملی از برنامهنویسی شی گرا داشته باشید که میتوانید بر اساس آن بسازید.
آنچه یاد خواهید گرفت با استفاده از Blazor، Razor Pages، الگوی Model-View-Controller (MVC) و سایر ویژگی های ASP.NET CoreBuild انواع خود را با برنامه نویسی شی گرا بنویسید، آزمایش کنید و اشکال زدایی را بنویسید، توابع را پرس و جو کنید و داده ها را دستکاری کنید. LINQ با استفاده از مدلهای Entity Framework Core پایگاههای داده را در برنامههای خود ادغام و بهروزرسانی کنید با استفاده از جدیدترین فناوریها، از جمله Web API و Minimal APIWho This Book Is For، سرویسهای قدرتمند بسازید و مصرف کنید.
این کتاب در درجه اول برای مبتدیان است، اما برنامه نویسان سطح متوسط C# و .NET که در گذشته با C# کار کرده اند و می خواهند با تغییرات ایجاد شده در چند سال گذشته برسند، اطلاعات مفید زیادی نیز در آن پیدا خواهند کرد. آشنایی قبلی با سی شارپ یا دات نت یک پیش نیاز نیست، اما قبل از شروع کار باید درک کلی از برنامه نویسی داشته باشید.
اگر قبلاً مهارتهای C# و NET دارید و میخواهید روی توسعه برنامهها تمرکز کنید، توصیه میکنیم به جای آن کتاب، برنامهها و سرویسهای Mark.
فهرست مطالبسلام سی شارپ، خوش آمدید.NET!صحبت کردن C#کنترل جریان، تبدیل انواع و مدیریت استثناها نوشتن، اشکال زدایی، و توابع تست ساخت انواع خود با برنامه نویسی شی گرا پیاده سازی رابط ها و ارث بردن کلاس ها با بسته بندیNEWorTypesT و TypesT. فایلها، جریانها، و سریالسازی کار با دادهها با استفاده از Entity Framework CoreQuerying و دستکاری دادهها با استفاده از LINQ معرفی توسعه وب با استفاده از وبسایتهای ASP.NET CoreBuilding با استفاده از ASP.NET Core Razor صفحهساخت وبسایتها با استفاده از Model-View-Controller، ساختن وبسایت Model-View-Controller.
فهرست مطالب :
Cover
Copyright
Contributors
Quick Chapter Reference
Table of Contents
Preface
Chapter 1: Hello, C#! Welcome, .NET!
Setting up your development environment
Choosing the appropriate tool and application type for learning
Pros and cons of the .NET Interactive Notebooks extension
Using Visual Studio Code for cross-platform development
Using GitHub Codespaces for development in the cloud
Using Visual Studio for Mac for general development
Using Visual Studio for Windows for general development
What I used
Deploying cross-platform
Downloading and installing Visual Studio 2022 for Windows
Microsoft Visual Studio for Windows keyboard shortcuts
Downloading and installing Visual Studio Code
Installing other extensions
Managing Visual Studio Code extensions at the command line
Understanding Microsoft Visual Studio Code versions
Microsoft Visual Studio Code keyboard shortcuts
Understanding .NET
Understanding .NET Framework
Understanding the Mono, Xamarin, and Unity projects
Understanding .NET Core
Understanding the journey to one .NET
Understanding Blazor WebAssembly versioning
Understanding .NET support
Understanding .NET Runtime and .NET SDK versions
Listing and removing versions of .NET
What is different about modern .NET?
Windows desktop development
Web development
Database development
Understanding .NET Standard
.NET platforms and tools used by the C# and .NET book editions
Topics covered by Apps and Services with .NET 7
Understanding intermediate language
Comparing .NET technologies
Building console apps using Visual Studio 2022
Managing multiple projects using Visual Studio 2022
Writing code using Visual Studio 2022
Compiling and running code using Visual Studio
Understanding the compiler-generated folders and files
Understanding top-level programs
Implicitly imported namespaces
Revealing the hidden code by throwing an exception
Adding a second project using Visual Studio 2022
Building console apps using Visual Studio Code
Managing multiple projects using Visual Studio Code
Writing code using Visual Studio Code
Compiling and running code using the dotnet CLI
Adding a second project using Visual Studio Code
Exploring code using .NET Interactive Notebooks
Using .NET Interactive Notebooks for the code in this book
Reviewing the folders and files for projects
Understanding the common folders and files
Understanding the solution code on GitHub
Making good use of the GitHub repository for this book
Raising issues with the book
Giving me feedback
Downloading solution code from the GitHub repository
Using Git with Visual Studio Code and the command line
Cloning the book solution code repository
Looking for help
Reading Microsoft documentation
Getting help for the dotnet tool
Getting definitions of types and their members
Looking for answers on Stack Overflow
Searching for answers using Google
Subscribing to the official .NET blog
Watching Scott Hanselman’s videos
A companion book to continue your learning journey
Practicing and exploring
Exercise 1.1 – Test your knowledge
Exercise 1.2 – Practice C# anywhere with a browser
Exercise 1.3 – Explore topics
Exercise 1.4 – Explore themes of modern .NET
Summary
Chapter 2: Speaking C#
Introducing the C# language
Understanding language versions and features
Project COOL
C# 1
C# 1.2
C# 2
C# 3
C# 4
C# 5
C# 6
C# 7.0
C# 7.1
C# 7.2
C# 7.3
C# 8
C# 9
C# 10
C# 11
Understanding C# standards
Discovering your C# compiler versions
How to output the SDK version
Enabling a specific language version compiler
Switching the C# compiler for .NET 6
Understanding C# grammar and vocabulary
Showing the compiler version
Understanding C# grammar
Statements
Comments
Blocks
Examples of statements and blocks
Understanding C# vocabulary
Comparing programming languages to human languages
Changing the color scheme for C# syntax
Help for writing correct code
Importing namespaces
Implicitly and globally importing namespaces
Verbs are methods
Nouns are types, variables, fields, and properties
Revealing the extent of the C# vocabulary
Working with variables
Naming things and assigning values
Literal values
Storing text
Verbatim strings
Raw string literals
Raw interpolated string literals
Summarizing options for storing text
Storing numbers
Storing whole numbers
Exploring whole numbers
Storing real numbers
Writing code to explore number sizes
Comparing double and decimal types
Storing Booleans
Storing any type of object
Storing dynamic types
Declaring local variables
Specifying the type of a local variable
Inferring the type of a local variable
Using target-typed new to instantiate objects
Getting and setting the default values for types
Exploring more about console apps
Displaying output to the user
Formatting using numbered positional arguments
Formatting using interpolated strings
Understanding format strings
Getting text input from the user
Simplifying the usage of the console
Importing a static type for a single file
Importing a static type for all code files in a project
Getting key input from the user
Passing arguments to a console app
Setting options with arguments
Handling platforms that do not support an API
Understanding async and await
Improving responsiveness for console apps
Practicing and exploring
Exercise 2.1 – Test your knowledge
Exercise 2.2 – Test your knowledge of number types
Exercise 2.3 – Practice number sizes and ranges
Exercise 2.4 – Explore topics
Summary
Chapter 3: Controlling Flow, Converting Types, and Handling Exceptions
Operating on variables
Exploring unary operators
Exploring binary arithmetic operators
Assignment operators
Exploring logical operators
Exploring conditional logical operators
Exploring bitwise and binary shift operators
Miscellaneous operators
Understanding selection statements
Branching with the if statement
Why you should always use braces with if statements
Pattern matching with the if statement
Branching with the switch statement
Pattern matching with the switch statement
Simplifying switch statements with switch expressions
Understanding iteration statements
Looping with the while statement
Looping with the do statement
Looping with the for statement
Looping with the foreach statement
Understanding how foreach works internally
Storing multiple values in an array
Working with single-dimensional arrays
Working with multi-dimensional arrays
Working with jagged arrays
List pattern matching with arrays
Summarizing arrays
Casting and converting between types
Casting numbers implicitly and explicitly
Converting with the System.Convert type
Rounding numbers
Understanding the default rounding rules
Taking control of rounding rules
Converting from any type to a string
Converting from a binary object to a string
Parsing from strings to numbers or dates and times
Errors using Parse
Avoiding exceptions using the TryParse method
Handling exceptions
Wrapping error-prone code in a try block
Catching all exceptions
Catching specific exceptions
Catching with filters
Checking for overflow
Throwing overflow exceptions with the checked statement
Disabling compiler overflow checks with the unchecked statement
Practicing and exploring
Exercise 3.1 – Test your knowledge
Exercise 3.2 – Explore loops and overflow
Exercise 3.3 – Practice loops and operators
Exercise 3.4 – Practice exception handling
Exercise 3.5 – Test your knowledge of operators
Exercise 3.6 – Explore topics
Summary
Chapter 4: Writing, Debugging, and Testing Functions
Writing functions
Understanding top-level programs and functions
Times table example
Writing a times table function
A brief aside about arguments and parameters
Writing a function that returns a value
Converting numbers from cardinal to ordinal
Calculating factorials with recursion
Documenting functions with XML comments
Using lambdas in function implementations
Debugging during development
Using the Visual Studio Code integrated terminal during debugging
Creating code with a deliberate bug
Setting a breakpoint and starting debugging
Using Visual Studio 2022
Navigating with the debugging toolbar
Using Visual Studio Code
Debugging windows
Stepping through code
Customizing breakpoints
Hot reloading during development
Hot reloading using Visual Studio 2022
Hot reloading using Visual Studio Code and the command line
Logging during development and runtime
Understanding logging options
Instrumenting with Debug and Trace
Writing to the default trace listener
Configuring trace listeners
Switching trace levels
Adding packages to a project in Visual Studio 2022
Adding packages to a project in Visual Studio Code
Reviewing project packages
Logging information about your source code
Unit testing
Understanding types of testing
Creating a class library that needs testing
Writing unit tests
Running unit tests using Visual Studio 2022
Running unit tests using Visual Studio Code
Fixing the bug
Throwing and catching exceptions in functions
Understanding usage errors and execution errors
Commonly thrown exceptions in functions
Understanding the call stack
Where to catch exceptions
Rethrowing exceptions
Implementing the tester-doer pattern
Problems with the tester-doer pattern
Practicing and exploring
Exercise 4.1 – Test your knowledge
Exercise 4.2 – Practice writing functions with debugging and unit testing
Exercise 4.3 – Explore topics
Summary
Chapter 5: Building Your Own Types with Object-Oriented Programming
Talking about OOP
Building class libraries
Creating a class library
Defining a class in a namespace
Understanding members
Instantiating a class
Importing a namespace to use a type
Avoiding a namespace conflict with a using alias
Renaming a type with a using alias
Understanding objects
Inheriting from System.Object
Storing data within fields
Defining fields
Understanding access modifiers
Setting and outputting field values
Storing a value using an enum type
Storing multiple values using an enum type
Storing multiple values using collections
Understanding generic collections
Making a field static
Making a field constant
Making a field read-only
Initializing fields with constructors
Defining multiple constructors
Writing and calling methods
Returning values from methods
Combining multiple returned values using tuples
C# language support for tuples
Naming the fields of a tuple
Deconstructing tuples
Deconstructing types
Defining and passing parameters to methods
Overloading methods
Passing optional and named parameters
Naming parameter values when calling methods
Controlling how parameters are passed
Simplified out parameters
Understanding ref returns
Splitting classes using partial
Controlling access with properties and indexers
Defining read-only properties
Defining settable properties
Requiring properties to be set during instantiation
Defining indexers
More about methods
Implementing functionality using methods
Implementing functionality using operators
Implementing functionality using local functions
Pattern matching with objects
Defining flight passengers
Enhancements to pattern matching in C# 9 or later
Working with records
Init-only properties
Understanding records
Positional data members in records
Simplifying data members in records
Practicing and exploring
Exercise 5.1 – Test your knowledge
Exercise 5.2 – Explore topics
Summary
Chapter 6: Implementing Interfaces and Inheriting Classes
Setting up a class library and console application
Making types safely reusable with generics
Working with non-generic types
Working with generic types
Raising and handling events
Calling methods using delegates
Defining and handling delegates
Defining and handling events
Implementing interfaces
Common interfaces
Comparing objects when sorting
Comparing objects using a separate class
Implicit and explicit interface implementations
Defining interfaces with default implementations
Managing memory with reference and value types
Defining reference and value types
How reference and value types are stored in memory
Equality of types
Defining struct types
Defining record struct types
Releasing unmanaged resources
Ensuring that Dispose is called
Working with null values
Making a value type nullable
Understanding null-related initialisms
Understanding nullable reference types
Controlling the nullability warning check feature
Declaring non-nullable variables and parameters
Checking for null
Checking for null in method parameters
Inheriting from classes
Extending classes to add functionality
Hiding members
Overriding members
Inheriting from abstract classes
Preventing inheritance and overriding
Understanding polymorphism
Casting within inheritance hierarchies
Implicit casting
Explicit casting
Avoiding casting exceptions
Using is to check a type
Using as to cast a type
Inheriting and extending .NET types
Inheriting exceptions
Extending types when you can’t inherit
Using static methods to reuse functionality
Using extension methods to reuse functionality
Writing better code
Treating warnings as errors
Understanding warning waves
Using an analyzer to write better code
Suppressing warnings
Fixing the code
Understanding common StyleCop recommendations
Practicing and exploring
Exercise 6.1 – Test your knowledge
Exercise 6.2 – Practice creating an inheritance hierarchy
Exercise 6.3 – Explore topics
Summary
Chapter 7: Packaging and Distributing .NET Types
The road to .NET 7
.NET Core 1.0
.NET Core 1.1
.NET Core 2.0
.NET Core 2.1
.NET Core 2.2
.NET Core 3.0
.NET Core 3.1
.NET 5.0
.NET 6.0
.NET 7.0
Improving performance with .NET 5 and later
Checking your .NET SDKs for updates
Understanding .NET components
Assemblies, NuGet packages, and namespaces
What is a namespace?
Dependent assemblies
Microsoft .NET project SDKs
Namespaces and types in assemblies
NuGet packages
Understanding frameworks
Importing a namespace to use a type
Relating C# keywords to .NET types
Mapping C# aliases to .NET types
Understanding native-sized integers
Revealing the location of a type
Sharing code with legacy platforms using .NET Standard
Understanding defaults for class libraries with different SDKs
Creating a .NET Standard 2.0 class library
Controlling the .NET SDK
Publishing your code for deployment
Creating a console app to publish
Understanding dotnet commands
Creating new projects
Getting information about .NET and its environment
Managing projects
Publishing a self-contained app
Publishing a single-file app
Reducing the size of apps using app trimming
Enabling assembly-level trimming
Enabling type-level and member-level trimming
Decompiling .NET assemblies
Decompiling using the ILSpy extension for Visual Studio 2022
Viewing source links with Visual Studio 2022
No, you cannot technically prevent decompilation
Packaging your libraries for NuGet distribution
Referencing a NuGet package
Fixing dependencies
Packaging a library for NuGet
Publishing a package to a public NuGet feed
Publishing a package to a private NuGet feed
Exploring NuGet packages with a tool
Testing your class library package
Porting from .NET Framework to modern .NET
Could you port?
Should you port?
Differences between .NET Framework and modern .NET
.NET Portability Analyzer
.NET Upgrade Assistant
Using non-.NET Standard libraries
Working with preview features
Requiring preview features
Enabling preview features
Practicing and exploring
Exercise 7.1 – Test your knowledge
Exercise 7.2 – Explore topics
Exercise 7.3 – Explore PowerShell
Summary
Chapter 8: Working with Common .NET Types
Working with numbers
Working with big integers
Working with complex numbers
Understanding quaternions
Generating random numbers for games and similar apps
Working with text
Getting the length of a string
Getting the characters of a string
Splitting a string
Getting part of a string
Checking a string for content
Joining, formatting, and other string members
Building strings efficiently
Pattern matching with regular expressions
Checking for digits entered as text
Regular expression performance improvements
Understanding the syntax of a regular expression
Examples of regular expressions
Splitting a complex comma-separated string
Activating regular expression syntax coloring
Improving regular expression performance with source generators
Storing multiple objects in collections
Common features of all collections
Improving performance by ensuring the capacity of a collection
Understanding collection choices
Lists
Dictionaries
Stacks
Queues
Sets
Collection methods summary
Working with lists
Working with dictionaries
Working with queues
Sorting collections
More specialized collections
Working with a compact array of bit values
Working with efficient lists
Working with immutable collections
Good practice with collections
Working with spans, indexes, and ranges
Using memory efficiently using spans
Identifying positions with the Index type
Identifying ranges with the Range type
Using indexes, ranges, and spans
Working with network resources
Working with URIs, DNS, and IP addresses
Pinging a server
Practicing and exploring
Exercise 8.1 – Test your knowledge
Exercise 8.2 – Practice regular expressions
Exercise 8.3 – Practice writing extension methods
Exercise 8.4 – Explore topics
Summary
Chapter 9: Working with Files, Streams, and Serialization
Managing the filesystem
Handling cross-platform environments and filesystems
Managing drives
Managing directories
Managing files
Managing paths
Getting file information
Controlling how you work with files
Reading and writing with streams
Understanding abstract and concrete streams
Understanding storage streams
Understanding function streams
Understanding stream helpers
Writing to text streams
Writing to XML streams
Simplifying disposal by using the using statement
Compressing streams
Working with tar archives
Reading and writing tar entries
Encoding and decoding text
Encoding strings as byte arrays
Encoding and decoding text in files
Reading and writing with random access handles
Serializing object graphs
Serializing as XML
Generating compact XML
Deserializing XML files
Serializing with JSON
High-performance JSON processing
Controlling JSON processing
New JSON extension methods for working with HTTP responses
Migrating from Newtonsoft to new JSON
Practicing and exploring
Exercise 9.1 – Test your knowledge
Exercise 9.2 – Practice serializing as XML
Exercise 9.3 – Explore topics
Summary
Chapter 10: Working with Data Using Entity Framework Core
Understanding modern databases
Understanding legacy Entity Framework
Using the legacy Entity Framework 6.3 or later
Understanding Entity Framework Core
Understanding Database First and Code First
Performance improvements in EF Core 7
Creating a console app for working with EF Core
Using a sample relational database
Using SQLite
Setting up SQLite for Windows
Setting up SQLite for macOS
Setting up SQLite for other OSes
Creating the Northwind sample database for SQLite
If you are using Visual Studio 2022
Managing the Northwind sample database with SQLiteStudio
Using the lightweight ADO.NET provider for SQLite
Using SQL Server for Windows
Setting up EF Core
Choosing an EF Core database provider
Connecting to a database
Defining the Northwind database context class
Defining EF Core models
Using EF Core conventions to define the model
Using EF Core annotation attributes to define the model
Using the EF Core Fluent API to define the model
Understanding data seeding with the Fluent API
Building EF Core models for the Northwind tables
Defining the Category and Product entity classes
Adding tables to the Northwind database context class
Setting up the dotnet-ef tool
Scaffolding models using an existing database
Customizing the reverse engineering templates
Configuring preconvention models
Querying EF Core models
Filtering included entities
Filtering and sorting products
Getting the generated SQL
Logging EF Core
Filtering logs by provider-specific values
Logging with query tags
Pattern matching with Like
Generating a random number in queries
Defining global filters
Loading patterns with EF Core
Eager loading entities using the Include extension method
Enabling lazy loading
Explicit loading entities using the Load method
Modifying data with EF Core
Inserting entities
Updating entities
Deleting entities
More efficient updates and deletes
Pooling database contexts
Working with transactions
Controlling transactions using isolation levels
Defining an explicit transaction
Defining Code First EF Core models
Practicing and exploring
Exercise 10.1 – Test your knowledge
Exercise 10.2 – Practice exporting data using different serialization formats
Exercise 10.3 – Explore topics
Exercise 10.4 – Explore NoSQL databases
Summary
Chapter 11: Querying and Manipulating Data Using LINQ
Why LINQ?
Comparing imperative and declarative language features
Writing LINQ expressions
What makes LINQ?
Building LINQ expressions with the Enumerable class
Understanding deferred execution
Filtering entities with Where
Targeting a named method
Simplifying the code by removing the explicit delegate instantiation
Targeting a lambda expression
Sorting entities
Sorting by a single property using OrderBy
Sorting by a subsequent property using ThenBy
Sorting by the item itself
Declaring a query using var or a specified type
Filtering by type
Working with sets and bags using LINQ
Using LINQ with EF Core
Building an EF Core model
Using Visual Studio 2022 with SQLite databases
Filtering and sorting sequences
Projecting sequences into new types
Joining and grouping sequences
Joining sequences
Group-joining sequences
Aggregating sequences
Be careful with Count!
Paging with LINQ
Sweetening LINQ syntax with syntactic sugar
Using multiple threads with parallel LINQ
Creating your own LINQ extension methods
Trying the chainable extension method
Trying the mode and median methods
Working with LINQ to XML
Generating XML using LINQ to XML
Reading XML using LINQ to XML
Practicing and exploring
Exercise 11.1 – Test your knowledge
Exercise 11.2 – Practice querying with LINQ
Exercise 11.3 – Explore topics
Summary
Chapter 12: Introducing Web Development Using ASP.NET Core
Understanding ASP.NET Core
Classic ASP.NET versus modern ASP.NET Core
Building websites using ASP.NET Core
Building websites using a content management system
Building web applications using SPA frameworks
Building web and other services
New features in ASP.NET Core
ASP.NET Core 1.0
ASP.NET Core 1.1
ASP.NET Core 2.0
ASP.NET Core 2.1
ASP.NET Core 2.2
ASP.NET Core 3.0
ASP.NET Core 3.1
Blazor WebAssembly 3.2
ASP.NET Core 5.0
ASP.NET Core 6.0
ASP.NET Core 7.0
Structuring projects
Structuring projects in a solution or workspace
Building an entity model for use in the rest of the book
Creating a class library for entity models using SQLite
Improving the class-to-table mapping
Creating a class library for a Northwind database context
Creating a class library for entity models using SQL Server
Testing the class libraries
Understanding web development
Understanding Hypertext Transfer Protocol
Understanding the components of a URL
Assigning port numbers for projects in this book
Using Google Chrome to make HTTP requests
Understanding client-side web development technologies
Practicing and exploring
Exercise 12.1 – Test your knowledge
Exercise 12.2 – Know your webbreviations
Exercise 12.3 – Explore topics
Summary
Chapter 13: Building Websites Using ASP.NET Core Razor Pages
Exploring ASP.NET Core
Creating an empty ASP.NET Core project
Testing and securing the website
Enabling stronger security and redirecting to a secure connection
Controlling the hosting environment
Enabling a website to serve static content
Creating a folder for static files and a web page
Enabling static and default files
Exploring ASP.NET Core Razor Pages
Enabling Razor Pages
Adding code to a Razor Page
Using shared layouts with Razor Pages
Using code-behind files with Razor Pages
Using Entity Framework Core with ASP.NET Core
Configuring Entity Framework Core as a service
Manipulating data using Razor Pages
Enabling a model to insert entities
Defining a form to insert a new supplier
Injecting a dependency service into a Razor Page
Using Razor class libraries
Disabling compact folders for Visual Studio Code
Creating a Razor class library
Implementing a partial view to show a single employee
Using and testing a Razor class library
Configuring services and the HTTP request pipeline
Understanding endpoint routing
Configuring endpoint routing
Reviewing the endpoint routing configuration in our project
Setting up the HTTP pipeline
Summarizing key middleware extension methods
Visualizing the HTTP pipeline
Implementing an anonymous inline delegate as middleware
Enabling request decompression support
Enabling HTTP/3 support
Practicing and exploring
Exercise 13.1 – Test your knowledge
Exercise 13.2 – Practice building a data-driven web page
Exercise 13.3 – Practice building web pages for console apps
Exercise 13.4 – Explore topics
Summary
Chapter 14: Building Websites Using the Model-View-Controller Pattern
Setting up an ASP.NET Core MVC website
Creating an ASP.NET Core MVC website
Creating the authentication database for SQL Server LocalDB
Exploring the default ASP.NET Core MVC website
Starting the MVC website project
Exploring visitor registration
Reviewing an MVC website project structure
Reviewing the ASP.NET Core Identity database
Exploring an ASP.NET Core MVC website
ASP.NET Core MVC initialization
The default MVC route
Controllers and actions
The ControllerBase class
The Controller class
The responsibilities of a controller
The view search path convention
Logging using the dependency service
Entity and view models
Views
Understanding how cache busting with Tag Helpers works
Customizing an ASP.NET Core MVC website
Defining a custom style
Setting up the category images
Razor syntax and expressions
Defining a typed view
Passing parameters using a route value
Model binders in more detail
Disambiguating action methods
Passing a route parameter
Passing a form parameter
Validating the model
Defining views with HTML Helper methods
Defining views with Tag Helpers
Cross-functional filters
Using a filter to secure an action method
Enabling role management and creating a role programmatically
Using a filter to define a custom route
Using a filter to cache a response
Using output caching
Output caching endpoints
Output caching MVC views
Varying cached data by query string
Querying a database and using display templates
Improving scalability using asynchronous tasks
Making controller action methods asynchronous
Practicing and exploring
Exercise 14.1 – Test your knowledge
Exercise 14.2 – Practice implementing MVC by implementing a category detail page
Exercise 14.3 – Practice improving scalability by understanding and implementing async action methods
Exercise 14.4 – Practice unit testing MVC controllers
Exercise 14.5 – Explore topics
Summary
Chapter 15: Building and Consuming Web Services
Building web services using the ASP.NET Core Web API
Understanding web service acronyms
Understanding HTTP requests and responses for Web APIs
Creating an ASP.NET Core Web API project
Reviewing the web service’s functionality
Creating a web service for the Northwind database
Creating data repositories for entities
Implementing a Web API controller
Understanding action method return types
Configuring the customer repository and Web API controller
Specifying problem details
Controlling XML serialization
Documenting and testing web services
Testing GET requests using a browser
Testing HTTP requests with the REST Client extension
Making GET requests using REST Client
Making other requests using REST Client
Understanding Swagger
Testing requests with Swagger UI
Enabling HTTP logging
Support for logging additional request headers in W3CLogger
Consuming web services using HTTP clients
Understanding HttpClient
Configuring HTTP clients using HttpClientFactory
Getting customers as JSON in the controller
Starting multiple projects
If you are using Visual Studio 2022
If you are using Visual Studio Code
Starting the web service and MVC client projects
Implementing advanced features for web services
Building web services using Minimal APIs
Testing the minimal weather service
Adding weather forecasts to the Northwind website home page
Practicing and exploring
Exercise 15.1 – Test your knowledge
Exercise 15.2 – Practice creating and deleting customers with HttpClient
Exercise 15.3 – Explore topics
Summary
Chapter 16: Building User Interfaces Using Blazor
Understanding Blazor
JavaScript and friends
Silverlight – C# and .NET using a plugin
WebAssembly – a target for Blazor
Blazor hosting models
Blazor components
What is the difference between Blazor and Razor?
Comparing Blazor project templates
Reviewing the Blazor Server project template
CSS and JavaScript isolation
Blazor routing to page components
How to define a routable page component
How to navigate Blazor routes
How to pass route parameters
Understanding base component classes
How to use the navigation link component with routes
Running the Blazor Server project template
Reviewing the Blazor WebAssembly project template
Deployment choices for Blazor WebAssembly apps
Differences between Blazor Server and Blazor WebAssembly projects
Similarities between Blazor Server and Blazor WebAssembly projects
Building components using Blazor Server
Defining and testing a simple Blazor Server component
Making the component a routable page component
Getting entities into a component
Abstracting a service for a Blazor component
Defining forms using the EditForm component
Building a shared customer detail component
Building customer create, edit, and delete components
Testing the customer components
Building components using Blazor WebAssembly
Configuring the server for Blazor WebAssembly
Configuring the client for Blazor WebAssembly
Testing the Blazor WebAssembly components and service
Improving Blazor WebAssembly apps
Practicing and exploring
Exercise 16.1 – Test your knowledge
Exercise 16.2 – Practice by creating a times table component
Exercise 16.3 – Practice by creating a country navigation item
Exercise 16.4 – Explore topics
Summary
Chapter 17: Epilogue
The next steps on your C# and .NET learning journey
Polishing your skills with design guidelines
A companion book to continue your learning journey
Other books to take your learning further
The eighth edition coming November 2023
Good luck!
Index
توضیحاتی در مورد کتاب به زبان اصلی :
An accessible guide for beginner-to-intermediate programmers to concepts, real-world applications, and latest features of C# 11 and .NET 7, with hands-on exercises using Visual Studio 2022 and Visual Studio Code
Key FeaturesExplore the newest additions to C# 11, the .NET 7 class libraries, and Entity Framework Core 7Create professional websites and services with ASP.NET Core 7 and BlazorBuild your confidence with step-by-step code examples and tips for best practicesBook Description
Extensively revised to accommodate the latest features that come with C# 11 and .NET 7, this latest edition of our guide will get you coding in C# with confidence.
You’ll learn object-oriented programming, writing, testing, and debugging functions, implementing interfaces, and inheriting classes. Next, you’ll take on .NET APIs for performing tasks like managing and querying data, working with the filesystem, and serialization. As you progress, you’ll also explore examples of cross-platform projects you can build and deploy, such as websites and services using ASP.NET Core.
Instead of distracting you with unnecessary graphical user interface code, the first eleven chapters will teach you about C# language constructs and many of the .NET libraries through simple console applications. In later chapters, having mastered the basics, you’ll then build websites, web services, and browser apps using ASP.NET Core, the Model-View-Controller (MVC) pattern, and Blazor.
C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals will give you a solid foundation to start building apps and services with confidence. By the end of this book, you’ll be able to create rich web experiences and have a solid grasp on object-oriented programming that you can build upon.
What you will learnBuild rich web experiences using Blazor, Razor Pages, the Model-View-Controller (MVC) pattern, and other features of ASP.NET CoreBuild your own types with object-oriented programmingWrite, test, and debug functionsQuery and manipulate data using LINQIntegrate and update databases in your apps using Entity Framework Core modelsBuild and consume powerful services using the latest technologies, including Web API and Minimal APIWho This Book Is For
This book is primarily for beginners, but intermediate-level C# and .NET programmers who have worked with C# in the past and want to catch up with the changes made in the past few years will also find plenty of useful information in it. Prior exposure to C# or .NET is not a prerequisite, but you should have a general understanding of programming before you jump in.
If you already have some C# and .NET skills and want to focus on developing apps, we recommend that you pick up Mark’s other .NET book, Apps and Services with .NET 7, instead.
Table of ContentsHello C#, Welcome .NET!Speaking C#Controlling Flow, Converting Types, and Handling ExceptionsWriting, Debugging, and Testing FunctionsBuilding Your Own Types with Object-Oriented ProgrammingImplementing Interfaces and Inheriting ClassesPackaging and Distributing .NET TypesWorking with Common .NET TypesWorking with Files, Streams, and SerializationWorking with Data Using Entity Framework CoreQuerying and Manipulating Data Using LINQIntroducing Web Development Using ASP.NET CoreBuilding Websites Using ASP.NET Core Razor PagesBuilding Websites Using the Model-View-Controller PatternBuilding and Consuming Web ServicesBuilding User Interface Components Using Blazor