How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?There is already an open DataReader associated with this Command which must be closed firstHow do I calculate someone's age in C#?LINQ query on a DataTableHow do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?How to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How can I get the application's path in a .NET console application?How can I generate random alphanumeric strings?How do I generate a random int number?What is a NullReferenceException, and how do I fix it?
Was any UN Security Council vote triple-vetoed?
What would happen to a modern skyscraper if it rains micro blackholes?
Paid for article while in US on F-1 visa?
What is the word for reserving something for yourself before others do?
Do infinite dimensional systems make sense?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
LaTeX: Why are digits allowed in environments, but forbidden in commands?
Did Shadowfax go to Valinor?
What defenses are there against being summoned by the Gate spell?
Why is consensus so controversial in Britain?
Replacing matching entries in one column of a file by another column from a different file
How old can references or sources in a thesis be?
I'm flying to France today and my passport expires in less than 2 months
Convert two switches to a dual stack, and add outlet - possible here?
Maximum likelihood parameters deviate from posterior distributions
High voltage LED indicator 40-1000 VDC without additional power supply
Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?
Malformed Address '10.10.21.08/24', must be X.X.X.X/NN or
Unable to deploy metadata from Partner Developer scratch org because of extra fields
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
Is it legal for company to use my work email to pretend I still work there?
DC-DC converter from low voltage at high current, to high voltage at low current
How to format long polynomial?
Watching something be written to a file live with tail
How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?
There is already an open DataReader associated with this Command which must be closed firstHow do I calculate someone's age in C#?LINQ query on a DataTableHow do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?How to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How can I get the application's path in a .NET console application?How can I generate random alphanumeric strings?How do I generate a random int number?What is a NullReferenceException, and how do I fix it?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?
Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM MyDb.dbo.viewName");
I would like to use this timeout to detect the too slow views. For each view I request a count but when my count take too much time I just stop it and count the next one.
Here is my full LINQPad code
void Main()
// In case of error "There is already an open DataReader associated with this Command which must be closed first."
// https://stackoverflow.com/q/6062192/196526
// Add MultipleActiveResultSets=true to connection string.
var biewsCount = b.V_sysobjects.Where(v => v.Type == "V").Count();
var bViewsDetail = Util.OnDemand<List<SysObject>>("Get Views Detail", () => GetViewsDetail("b", b.V_sysobjects.Where(v => v.Type == "V").Select(v => v.Name).ToList()));
bViewsDetail.Dump();
public List<SysObject> GetViewsDetail(string database, List<string> objectNames)
var result = new List<SysObject>();
foreach (var name in objectNames)
Console.Write($"database.dbo.name");
// I should add a timeout stuff here or before
var count = (int)Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Select(y => y).Single();
Console.Write($" countn");
result.Add(new SysObject
Database = database,
ObjectName = name,
Rows = count
);
return result;
public class SysObject
public string Database get; set;
public string ObjectName get; set;
public string ObjectType get; set;
public string IndexName get; set;
public long Rows get; set;
public long? TotalPages get; set;
public long? UsedPages get; set;
public long? DataPages get; set;
public long? TotalSpaceMB get; set;
public long? UsedSpaceMB get; set;
public long? DataSpaceMB get; set;
c# linqpad
add a comment |
How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?
Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM MyDb.dbo.viewName");
I would like to use this timeout to detect the too slow views. For each view I request a count but when my count take too much time I just stop it and count the next one.
Here is my full LINQPad code
void Main()
// In case of error "There is already an open DataReader associated with this Command which must be closed first."
// https://stackoverflow.com/q/6062192/196526
// Add MultipleActiveResultSets=true to connection string.
var biewsCount = b.V_sysobjects.Where(v => v.Type == "V").Count();
var bViewsDetail = Util.OnDemand<List<SysObject>>("Get Views Detail", () => GetViewsDetail("b", b.V_sysobjects.Where(v => v.Type == "V").Select(v => v.Name).ToList()));
bViewsDetail.Dump();
public List<SysObject> GetViewsDetail(string database, List<string> objectNames)
var result = new List<SysObject>();
foreach (var name in objectNames)
Console.Write($"database.dbo.name");
// I should add a timeout stuff here or before
var count = (int)Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Select(y => y).Single();
Console.Write($" countn");
result.Add(new SysObject
Database = database,
ObjectName = name,
Rows = count
);
return result;
public class SysObject
public string Database get; set;
public string ObjectName get; set;
public string ObjectType get; set;
public string IndexName get; set;
public long Rows get; set;
public long? TotalPages get; set;
public long? UsedPages get; set;
public long? DataPages get; set;
public long? TotalSpaceMB get; set;
public long? UsedSpaceMB get; set;
public long? DataSpaceMB get; set;
c# linqpad
LikeUtil.CurrentDataContext.CommantTimeout
?
– DavidG
Mar 4 at 10:08
Not changing anything
– Bastien Vandamme
Mar 4 at 10:15
Are you using EntityFramework?
– Arif
Mar 8 at 2:14
@Arif Is use LINQPad so I'm using Entity Framework
– Bastien Vandamme
Mar 8 at 2:22
Did you have any properties likeUtil.CurrentDataContext.Database.CommandTimeout
?
– Arif
Mar 8 at 2:39
add a comment |
How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?
Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM MyDb.dbo.viewName");
I would like to use this timeout to detect the too slow views. For each view I request a count but when my count take too much time I just stop it and count the next one.
Here is my full LINQPad code
void Main()
// In case of error "There is already an open DataReader associated with this Command which must be closed first."
// https://stackoverflow.com/q/6062192/196526
// Add MultipleActiveResultSets=true to connection string.
var biewsCount = b.V_sysobjects.Where(v => v.Type == "V").Count();
var bViewsDetail = Util.OnDemand<List<SysObject>>("Get Views Detail", () => GetViewsDetail("b", b.V_sysobjects.Where(v => v.Type == "V").Select(v => v.Name).ToList()));
bViewsDetail.Dump();
public List<SysObject> GetViewsDetail(string database, List<string> objectNames)
var result = new List<SysObject>();
foreach (var name in objectNames)
Console.Write($"database.dbo.name");
// I should add a timeout stuff here or before
var count = (int)Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Select(y => y).Single();
Console.Write($" countn");
result.Add(new SysObject
Database = database,
ObjectName = name,
Rows = count
);
return result;
public class SysObject
public string Database get; set;
public string ObjectName get; set;
public string ObjectType get; set;
public string IndexName get; set;
public long Rows get; set;
public long? TotalPages get; set;
public long? UsedPages get; set;
public long? DataPages get; set;
public long? TotalSpaceMB get; set;
public long? UsedSpaceMB get; set;
public long? DataSpaceMB get; set;
c# linqpad
How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?
Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM MyDb.dbo.viewName");
I would like to use this timeout to detect the too slow views. For each view I request a count but when my count take too much time I just stop it and count the next one.
Here is my full LINQPad code
void Main()
// In case of error "There is already an open DataReader associated with this Command which must be closed first."
// https://stackoverflow.com/q/6062192/196526
// Add MultipleActiveResultSets=true to connection string.
var biewsCount = b.V_sysobjects.Where(v => v.Type == "V").Count();
var bViewsDetail = Util.OnDemand<List<SysObject>>("Get Views Detail", () => GetViewsDetail("b", b.V_sysobjects.Where(v => v.Type == "V").Select(v => v.Name).ToList()));
bViewsDetail.Dump();
public List<SysObject> GetViewsDetail(string database, List<string> objectNames)
var result = new List<SysObject>();
foreach (var name in objectNames)
Console.Write($"database.dbo.name");
// I should add a timeout stuff here or before
var count = (int)Util.CurrentDataContext.ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Select(y => y).Single();
Console.Write($" countn");
result.Add(new SysObject
Database = database,
ObjectName = name,
Rows = count
);
return result;
public class SysObject
public string Database get; set;
public string ObjectName get; set;
public string ObjectType get; set;
public string IndexName get; set;
public long Rows get; set;
public long? TotalPages get; set;
public long? UsedPages get; set;
public long? DataPages get; set;
public long? TotalSpaceMB get; set;
public long? UsedSpaceMB get; set;
public long? DataSpaceMB get; set;
c# linqpad
c# linqpad
edited Mar 8 at 2:30
Bastien Vandamme
asked Mar 4 at 9:56
Bastien VandammeBastien Vandamme
6,1712268127
6,1712268127
LikeUtil.CurrentDataContext.CommantTimeout
?
– DavidG
Mar 4 at 10:08
Not changing anything
– Bastien Vandamme
Mar 4 at 10:15
Are you using EntityFramework?
– Arif
Mar 8 at 2:14
@Arif Is use LINQPad so I'm using Entity Framework
– Bastien Vandamme
Mar 8 at 2:22
Did you have any properties likeUtil.CurrentDataContext.Database.CommandTimeout
?
– Arif
Mar 8 at 2:39
add a comment |
LikeUtil.CurrentDataContext.CommantTimeout
?
– DavidG
Mar 4 at 10:08
Not changing anything
– Bastien Vandamme
Mar 4 at 10:15
Are you using EntityFramework?
– Arif
Mar 8 at 2:14
@Arif Is use LINQPad so I'm using Entity Framework
– Bastien Vandamme
Mar 8 at 2:22
Did you have any properties likeUtil.CurrentDataContext.Database.CommandTimeout
?
– Arif
Mar 8 at 2:39
Like
Util.CurrentDataContext.CommantTimeout
?– DavidG
Mar 4 at 10:08
Like
Util.CurrentDataContext.CommantTimeout
?– DavidG
Mar 4 at 10:08
Not changing anything
– Bastien Vandamme
Mar 4 at 10:15
Not changing anything
– Bastien Vandamme
Mar 4 at 10:15
Are you using EntityFramework?
– Arif
Mar 8 at 2:14
Are you using EntityFramework?
– Arif
Mar 8 at 2:14
@Arif Is use LINQPad so I'm using Entity Framework
– Bastien Vandamme
Mar 8 at 2:22
@Arif Is use LINQPad so I'm using Entity Framework
– Bastien Vandamme
Mar 8 at 2:22
Did you have any properties like
Util.CurrentDataContext.Database.CommandTimeout
?– Arif
Mar 8 at 2:39
Did you have any properties like
Util.CurrentDataContext.Database.CommandTimeout
?– Arif
Mar 8 at 2:39
add a comment |
2 Answers
2
active
oldest
votes
This is a bug in LINQPad. The ExecuteQueryDynamic
method should honor the DataContext
's CommandTimeout
.
This has now been fixed (as of 5.37.4, currently in beta).
Note that Util.CurrentDataContext
is redundant unless the containing method is static. The Select(y=>y)
is also redundant. So in your example, you can just do this:
CommandTimeout = 1;
var count = (int)ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Single();
add a comment |
As far as I know, apart from setting the command or connection timeouts in the client, there is no way to change timeouts on a query in the server.
You can try this way, that works fine for me:
Just before running your actual query, set it for your query
SET LOCK_TIMEOUT 1000; --1 second
and after running your query set it back to original value. The default value for running query is 600 seconds.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54980703%2fhow-can-i-set-a-timeout-om-my-query-on-linqpad-on-executequerydynamic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is a bug in LINQPad. The ExecuteQueryDynamic
method should honor the DataContext
's CommandTimeout
.
This has now been fixed (as of 5.37.4, currently in beta).
Note that Util.CurrentDataContext
is redundant unless the containing method is static. The Select(y=>y)
is also redundant. So in your example, you can just do this:
CommandTimeout = 1;
var count = (int)ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Single();
add a comment |
This is a bug in LINQPad. The ExecuteQueryDynamic
method should honor the DataContext
's CommandTimeout
.
This has now been fixed (as of 5.37.4, currently in beta).
Note that Util.CurrentDataContext
is redundant unless the containing method is static. The Select(y=>y)
is also redundant. So in your example, you can just do this:
CommandTimeout = 1;
var count = (int)ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Single();
add a comment |
This is a bug in LINQPad. The ExecuteQueryDynamic
method should honor the DataContext
's CommandTimeout
.
This has now been fixed (as of 5.37.4, currently in beta).
Note that Util.CurrentDataContext
is redundant unless the containing method is static. The Select(y=>y)
is also redundant. So in your example, you can just do this:
CommandTimeout = 1;
var count = (int)ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Single();
This is a bug in LINQPad. The ExecuteQueryDynamic
method should honor the DataContext
's CommandTimeout
.
This has now been fixed (as of 5.37.4, currently in beta).
Note that Util.CurrentDataContext
is redundant unless the containing method is static. The Select(y=>y)
is also redundant. So in your example, you can just do this:
CommandTimeout = 1;
var count = (int)ExecuteQueryDynamic($"SELECT count(*) FROM database.dbo.name").Single();
answered Mar 13 at 7:33
Joe AlbahariJoe Albahari
24.2k55980
24.2k55980
add a comment |
add a comment |
As far as I know, apart from setting the command or connection timeouts in the client, there is no way to change timeouts on a query in the server.
You can try this way, that works fine for me:
Just before running your actual query, set it for your query
SET LOCK_TIMEOUT 1000; --1 second
and after running your query set it back to original value. The default value for running query is 600 seconds.
add a comment |
As far as I know, apart from setting the command or connection timeouts in the client, there is no way to change timeouts on a query in the server.
You can try this way, that works fine for me:
Just before running your actual query, set it for your query
SET LOCK_TIMEOUT 1000; --1 second
and after running your query set it back to original value. The default value for running query is 600 seconds.
add a comment |
As far as I know, apart from setting the command or connection timeouts in the client, there is no way to change timeouts on a query in the server.
You can try this way, that works fine for me:
Just before running your actual query, set it for your query
SET LOCK_TIMEOUT 1000; --1 second
and after running your query set it back to original value. The default value for running query is 600 seconds.
As far as I know, apart from setting the command or connection timeouts in the client, there is no way to change timeouts on a query in the server.
You can try this way, that works fine for me:
Just before running your actual query, set it for your query
SET LOCK_TIMEOUT 1000; --1 second
and after running your query set it back to original value. The default value for running query is 600 seconds.
answered Mar 8 at 4:37
ArifArif
2,80312542
2,80312542
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54980703%2fhow-can-i-set-a-timeout-om-my-query-on-linqpad-on-executequerydynamic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Like
Util.CurrentDataContext.CommantTimeout
?– DavidG
Mar 4 at 10:08
Not changing anything
– Bastien Vandamme
Mar 4 at 10:15
Are you using EntityFramework?
– Arif
Mar 8 at 2:14
@Arif Is use LINQPad so I'm using Entity Framework
– Bastien Vandamme
Mar 8 at 2:22
Did you have any properties like
Util.CurrentDataContext.Database.CommandTimeout
?– Arif
Mar 8 at 2:39