Uploaded by Ruzibek Salimov

5-mavzu sirtqi

advertisement
Qiymatlar turlari va havola turlari
Reja


To’plamlar ustida amallar
o To’plamlar birlashmasi
o To’plamlar kesishmasi
o To’plamlar ayirmasi
Entity Frameworkda to’plamlar birlashmasi va kesishmasi
To‘plamlar ustida amallar
To’plamlar birlashmasi.
Ta’rif. Har qanday ikkita to‘plamning barcha elementlaridan, ularni
takrorlamasdan, tuzilgan to‘plamga shu to‘plamlarning birlashmasi (yoki
yig‘indisi) deb ataladi.
1-shakl
To’plamlar kesishmasi.
Ta’rif. Har qanday ikkita to‘plamning barcha umumiy elementlaridan tuzilgan
to‘plamga to‘plamlarning kesishmasi (yoki ko‘paytmasi) deyiladi.
2-shakl
3-shakl
Entity Frameworkda to’plamlar birlashmasi


Set Operator: Union
The Union extension method requires two collections and returns a new
collection that includes distinct elements from both the collections. Consider
the following example.

The Union extension method doesn't return the correct result for the
collection of complex types. You need to implement IEqualityComparer
interface in order to get the correct result from Union method.

Implement IEqualityComparer interface for Student class as below:

Now, you can pass above StudentComparer class in the Union extension
method to get the correct result:
Query Syntax


The Union operator is Not Supported in C# & VB.Net Query syntax.
However, you can use Union method on query variable or wrap whole query
into brackets and then call Union().
The following figure shows how each set operators works on the collections:
To’plamlar kesishmasi






Set Operator: Intersect
The Intersect extension method requires two collections. It returns a new
collection that includes common elements that exists in both the collection.
Consider the following example.
The Intersect extension method doesn't return the correct result for the
collection of complex types. You need to implement IEqualityComparer
interface in order to get the correct result from Intersect method.
Implement IEqualityComparer interface for Student class as shown below:
The Intersect operator is Not Supported in C# & VB.Net Query syntax.
However, you can use the Intersect method on a query variable or wrap
whole query into brackets and then call Intersect().
The following figure shows how each set operators works on the collections:
Foydalanilgan adabiyotlar



https://www.entityframeworktutorial.net/efcore/create-model-for-existingdatabase-in-ef-core.aspx
https://www.tutorialsteacher.com/linq/linq-set-operators-union
https://www.tutorialsteacher.com/linq/linq-set-operators-intersect
Download