sql server - Why is C# console application not returning result on LINQ Select with data -
i'm writing rather complicated database scanning utility using console application, reason i'm running basic of problems when attempt simple linq select on database table data.
when database table has no data, query returns control console application.
when table has data, sql server shows "suspended" , "async_network_io".
thank in advance assistance.
program.cs looks follows:
class program { static void main(string[] args) { datamodels dm = new datamodels(); list<string> lsreturn = dm.returndatafromtablex(); } }
datamodels.cs looks follows:
class datamodels { public list<string> returndatafromtablex() { return _dataentities.<table_name>.select(x => x.<column_name>).tolist(); } }
first can try
class datamodels { public ienumerable<string> returndatafromtablex() { return _dataentities.<table_name>.select(x => x.<column_name>); } }
it track returned row in table , if processing not long, should enough or alternatively ready block block in case connection opened read portion of data each time required:
var page = 0; var step = 10; var block = _dataentities.<table_name>.skip(page * step).take(step).select(x => x.<column_name>).tolist(); while (block.count > 0) { foreach (var item in block) { yield return item; } page++; block = _dataentities.<table_name>.skip(page * step).take(step).select(x => x.<column_name>).tolist(); }
wiki
Comments
Post a Comment