Name);
foreach (var itms in lst)
Console.WriteLine(itms.Name);
Here the execution takes place only once when the resultant rows in the variable
icecreams is converted to a list using the ToList operator, and assigned to the
variable, lst. Now we can use this variable lst in the future, any number of times.
This avoids the multiple execution of the query or deferred execution.
Identifying Objects
In object-oriented programming, all objects have references. So, if we assign an object
to two different variables, the value is not assigned to the variables. The variables
will refer to the same object using the object identity. When we execute queries, the
data is returned in the form of rows from the relational database. If we execute the
same query, another set of same rows is returned from the database because the rows
do not have any key to identify them. The primary key which exists in the database
is to identify the rows for uniqueness. So, whenever the same data is fetched from
the database multiple times from the front end application, it comes as different
instances.
Pages:
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172