DataTable in a query using linq

Statement receive variables:
protected EnumerableRowCollection Account_data = null;

// query the data into the variable:
Private void Select_258 () {
. Data_258 = dbs_07.Select_258 () the Tables [0];
Booking_data data_258.AsEnumerable = ();
}

The extraction condition data //
var result = Account_data.Where (p => p.Field ( "BRoomID") == BRoomID) .ToList ();

                    bool BIs_Alone = Convert.ToBoolean(result[0]["BIs_Alone"]); //是否个人
                    bool BIs_Team = Convert.ToBoolean(result[0]["BIs_Team"]); //是否团队

// Why use Linq query?
Reason: the project
Here Insert Picture Description
in a for loop, to avoid a large number of the number of requests the server directly in the value of re Session, very much high speed.

In the past wording:

for loop, DataTable.Rows.Count, the value in the loop
for (int I = 0, I <DataTable.Rows.Count, I ++)
IF (the DataTable.Rows [I] [ "RoomID"]. the ToString () == RoomID)
{
...
Continue;
}
fast as Linq query, the more data, the more obvious advantages linq reflected;

Note: When using linq Field, data types, and some of the same database.

Published 115 original articles · won praise 36 · views 9877

Guess you like

Origin blog.csdn.net/weixin_44548307/article/details/103628208