Async Practice Networking and Database Access

In production, we need to talk to databases, local and remote storage (servers). From the point of the developers’ view, these operations can take a long time. We would like to ask for the operation to happen on the background thread and we can carry on doing other work on the calling thread. We need…

Thread in C#

In order to under Thread in C#, we need to understand how the operating system works. A Thread of execution is the smallest sequence of programmed instructions that can be managed independently by a Scheduler. Threads and Processes are different in Operating Systems, a thread is a component of a process; multiple Threads can exist…

Create an XML file by using LINQ

The XML file is widely used in our development, it is very handy when our application needs to communicate with other application or service. LINQ syntax can be used to create an XML file in our practice. Background Data Source Based on the above data, we have a Car class in our code. In order…

Data Grouping in LINQ

Data Grouping is another feature of LINQ syntax, which can group data based on data collection’s filter element or key character. The keyword used in Data Grouping is group and on. Data Source Manufacturer Sample Car Sample Class Definition Car Class Manufacturer Class Data Grouping Implementation As we can see, we group the data via…

Join Data in LINQ

Sometimes, we need to combine two sets of data in our development. In LINQ, we join data by stitching the common content. The syntax is join A on B.content equals A.content In this case, B.content equal A.content. Data Source Manufacturer Sample Car Data Sample As we can see, the two data sets share a common…

Anonymous Type in LINQ

Anonymous type in LINQ query is useful when parts of the data are needed, especially the output type is relatively large. Convert Data into Object The first step of LINQ process is to turn data into objects. Function ProcessFile() turns the data source into object. Helper function Data Source Data source in this post is…

LINQ Study Note – 02

Three Actions In LINQ, we always work with objects, instead of the data source. Therefore, in the LINQ pattern, we always have three actions. Obtain the data source Create the query Execute the query Regarding the data source, the data source LINQ work with should support generic IEnumerable<T> interface; In other words, LINQ serves as…

LINQ Study Note – 01

LINQ works by using extension methods in C#, as LINQ won’t change the IEnumerator behind the scene. Func and Action Func type is common when we use LINQ to process, fetch and modify data or data collection in C#. Func itself can take 17 generic types as parameters. The last generic type parameter describes the…

Function Body Expression in C#

Function body expression is convenient when we make a less complicated function in C#. The body expression can decrease our workload dramatically when we are developing a large project. Original Function Function body Expression The function above is quite simple. It takes three parameters and returns the average value of the three parameters. The following…