Datareader object has method ExecuteReader, which has overload version that takes CommandBehavior enumeration as parameter.
- CommandBehavior.CloseConnection
When you pass above values as argument to ExecuteReader
1. there is no need to close connection explicitly connection get close when you close your reader.
//No need to close connection you just have to write
reader.Close();
2. It usefull when you pass reader to another method for processing data.
- CommandBehavior.SinglerRow
passing this as parameter , increase performance when you are executing query and retriving single row for exmaple by id field of table.
- CommandBehavior.SequentialAccess
usefull when reading binary field data, which reduces the memory overhead for large binary fields.
thank you very much, CommandBehavior.CloseConnection helped me on asp.net core.
ReplyDeleteregards