.net-4.0

This SqlTransaction has completed; it is no longer usable

☆樱花仙子☆ 提交于 2019-12-22 05:43:10
问题 I am using Linq to SQL with SQL Server 2008 SP2, my application is WinForm .net 4 I am importing into SQL Server 200,000 records. I am creating the objects and attach them to the datacontext on the "insertonsubmit". I then do "submitChanges" every 100 records. I have NO TRANSACTION what so ever. I get this error "This SqlTransaction has completed; it is no longer usable." with stack at System.Data.SqlClient.SqlTransaction.ZombieCheck() at System.Data.SqlClient.SqlTransaction.Rollback() at

The dreaded “parameter was not bound in the specified LINQ to Entities query expression” exception

旧城冷巷雨未停 提交于 2019-12-22 05:42:07
问题 I am trying to get an understanding of expressions. I am hitting the dreaded "parameter was not bound in the specified LINQ to Entities query expression" exception. I have seen Skeet answer this before as well as others online. However I just cannot "see" the problem. I am using Colin Meek's example http://blogs.msdn.com/b/meek/archive/2008/05/02/linq-to-entities-combining-predicates.aspx and Matt Warren's VisitorExpression class http://blogs.msdn.com/b/mattwar/archive/2007/07/31/linq

Can't Reference Dynamic Objects in Embedded ASPX code

喜你入骨 提交于 2019-12-22 05:33:33
问题 I'm creating a List member variable during my Page_Init event. I'm having a problem referencing the objects in the list from my embedded C# code in the *.aspx page. The error is a Runtime Binder Exception that says "'object' does not contain a definition for 'JobID'". When the debugger is invoked, I can see that the foreach loop's variable j does indeed have a dynamic property named JobID and it's filled with an int value. So, my question is why my embedded C# code can't work with the dynamic

Nested Transactions in .NET

主宰稳场 提交于 2019-12-22 04:46:12
问题 How can I perform the equivalent of this? My understanding is that this is impossible with TransactionScopes but I'd like to accomplish the equivalent in some other way: Business Logic class: public bool Bar() { try { using (var tsWork = new TransactionScope()) { ComplicatedDataImportCode(somedata); FlagRecordInDatabaseAsImported(); // this is the same record that's modified in the catch tsWork.Complete(); return true; } catch (DuplicateDataException err) { // if we got here, the above

Action/Lambda Expression Memory Management Question

亡梦爱人 提交于 2019-12-22 04:32:59
问题 I'm storing an action in a local variable, then I'm using after that local variable is out of scope. Is it in danger of being cleaned up before I use it? Here is an example: public List<object> GetMaps() { Action<Customer1, Customer2> baseMap = (Customer1 c1, Customer2 c2) => { c2.FirstName = c1.FirstName; }; var list = new List<object>() { new Action<SpecialCustomer1 c1, SpecialCustomer2 c2>() { baseMap(c1, c2); c2.SpecialProperty = c1.SpecialProperty; }, new Action<SpecialCustomer1 c1,

Conditional compilation for .NET 4 [duplicate]

[亡魂溺海] 提交于 2019-12-22 04:32:23
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Conditional compilation and framework targets I have some code that works in .NET 4, but it does not work in .NET 3.5. In .NET 3.5 it requires to use interop calls to Windows. I would like using a "ifdef" to use a different code path in both cases (eventually I will deprecate the .NET 3.5 code). Is there a pre-defined directive value to identify when the code is compiled with .NET 4? Is there a good link with

Where has Microsoft's WPF/Silverlight Charting gone in .NET 4.0?

别等时光非礼了梦想. 提交于 2019-12-22 04:27:19
问题 Forgive me for being a little naive perhaps, but it seems that System.Windows.Controls.DataVisualization.Charting has vanished from VS2010, and blend 4. I'm trying to make a bar graph with a line overlayed, but can't even get started because I can't find the appropriate controls. I know I could use an external graphing package, but I'd like to try the inbuilt controls first. 回答1: You mention Blend so I assume that you are refering to the WPF/Silverlight chart controls. The System.Windows

How do I test for typeof(dynamic)?

送分小仙女□ 提交于 2019-12-22 04:21:51
问题 I've got a generic method TResult Foo<TSource, TResult>(IEnumerable<TSource> source) and if TResult is declared as dynamic I want to execute a different code path than for other type declarations. For regular types you can do stuff like: if (typeof(TResult) == typeof(int)) return ExpressionFactory.CreateExpandoFunction<TSource, TResult>(); But if (typeof(TResult) == typeof(dynamic)) does not compile. Is there anyway to make this sort of determination at runtime when the method is called with

How do I test for typeof(dynamic)?

送分小仙女□ 提交于 2019-12-22 04:21:06
问题 I've got a generic method TResult Foo<TSource, TResult>(IEnumerable<TSource> source) and if TResult is declared as dynamic I want to execute a different code path than for other type declarations. For regular types you can do stuff like: if (typeof(TResult) == typeof(int)) return ExpressionFactory.CreateExpandoFunction<TSource, TResult>(); But if (typeof(TResult) == typeof(dynamic)) does not compile. Is there anyway to make this sort of determination at runtime when the method is called with

Thread.sleep vs Monitor.Wait vs RegisteredWaitHandle?

自古美人都是妖i 提交于 2019-12-22 04:02:03
问题 (the following items has different goals , but im interesting knowing how they "PAUSEd") questions Thread.sleep - Does it impact performance on a system ?does it tie up a thread with its wait ? what about Monitor.Wait ? what is the difference in the way they "wait"? do they tie up a thread with their wait ? what about RegisteredWaitHandle ? This method accepts a delegate that is executed when a wait handle is signaled. While it’s waiting, it doesn’t tie up a thread. so some thread are paused