.net

How can i query for null values in entity framework?

I want to execute a query like this var result = from entry in table where entry.something == null select entry; and get an IS NULL generated. Edited: After the first two answers i feel the need to clarify that I'm using Entity Framework and not Linq to SQL. The object.Equals() method doe...

Visual Studio F6 stopped working. It no longer builds the project.

I'm using VS2008, been using it for quite some time now, and since I hate using the mouse while developing, I'm always using F6 to build the solution, or Shift+F6 to build the current project. What's weird though is for some strange reason, it simply stopped working over the last few days. In fact, when I pull down the Build menu, next t...

Why does Visual Studio displays some of my exceptions on the following line instead of the faulting line?

The usual behaviour of VS is to display in yellow the faulting line : int i = 1; switch (i) { default: throw new NotImplementedException(); //this will be yellow } However, quite frequently, I've witnessed that the wrong line is coloured, like in this example : int i = 1; switch (i)...

LINQ Performance for Large Collections

I have a large collection of strings (up to 1M) alphabetically sorted. I have experimented with LINQ queries against this collection using HashSet, SortedDictionary, and Dictionary. I am static caching the collection, it's up to 50MB in size, and I'm always calling the LINQ query against the cached collection. My problem is as follows...

Naming, declaring and defining delegates and events conventions

How do you name delegates, events and instance of events? I use this: delegate void OnSomethingHandler(); event OnSomethingHandler onSomething; Is this an accepted way? Notice lower and upper cases Where do you place delegates and events? I usually put delegates in an a namespace best reflecting them: mynamespace.Def.SomethingL...

Encrypting web.config using Protected Configuration pointless?

I must be missing something... So I am in the process of figuring out the best way of encrypting the database connection string and sql session state connection info in web.config. I quickly find a walk through on msdn explaining using protected configuration to encrypt parts of the web.config: MSDN walkthrough on using Protected Config...

Working with XML document type definitions in .net

Is it possible to import an XML DTD into Visual Studio in order to generate a proxy class? I have a third party .dll that I need to interface with that is designed like an XML service. The interface into the .dll is all driven by XML inputs, and returns output as XML. The nice thing about it is that all the input and output types are we...

How can I detect .net 3.5 in WiX?

I'm trying to detect which version .NET is installed using WiX. I've tried: <Condition Message='This setup requires the .NET Framework 3.5 or higher.'> <![CDATA[MsiNetAssemblySupport >= "3.5.0.0"]]> </Condition> But that won't work, because the MsiNetAssemblySupport property checks the version of fusion.dll, which wasn't updated fr...

Mapping LDAP Data to .NET Classes (LINQ)

Hey All, I've been using several different tuts in order to build a LINQ-to-LDAP model. I've just about got it complete, but I'm running into some issues trying to bind the data returned to a class. I do the reverse part by assigning custom attributes to the properties of the class that are the actual names of the database fields. ...

How can I keep a Connection open when performing multiple queries?

I am using multiple queries to pull data from the same server in my application. The issue is that I have to open a new connection every time I have a new query. Is it even possible to: Open the connection Run query Pull results Run another query Pull another result Run final query Pull another result Close connection. ...

.net Detect disconnect with ReceiveAsync

Well as the title says how can i detect a disconnect with "ReceiveAsync" with all other .net network patterns you could just look if you recived 0 bytes or if any exception was throw however this does not seem to be true any more with this pattern... My first recive return 0 bytes but the second works thats why im confused.... ...

How to compare Dates in C#

Is there a way to compare 2 DateTime variables in Linq2Sql but to disregard the Time part. The app stores items in the DB and adds a published date. I want to keep the exact time but still be able to pull by the date itself. I want to compare 12/3/89 12:43:34 and 12/3/89 11:22:12 and have it disregard the actual time of day so both of ...

Script to download email from Gmail and save to a SQL server?

Does anyone know of a script to download email from Gmail and store it to a SQL server? (for backup purposes) I am looking for a .NET solution (C#). ...

Load assembly and change source, is it possible and how?

I'm writing .NET On-the-Fly compiler for CLR scripting and want to implement next idea: there is a template file with C# code, I want to read it, create an assembly, load it and amplify source on-the-fly. How can I do that? ...

PictureBoxes and Zorder [.NET]

Hello, I have difficulties with showing multiple (up to 5) pictureboxes on top each other, but able to see all of them. Only first and last will show up. I show them from bottom to top, set their locations correctly and using BringToFront() function. Does anybody have a solution (if any)? Thanks for help! ...

XML and DataContractSerializer

I have classes like this [DataContract(Namespace = "")] public class Foo { [DataMember(Order = 0)] Bar bar; } [DataContract(Namespace = "")] public class Bar { Baz baz; [DataMember(Order = 0)] string TheBaz { get { baz.ToString(); } set { SomeOtherCode(value); } } } I want this to generate...

How to make a window always stay on top in .Net?

I have a C# winforms app that runs a macro in another program. The other program will continually pop up windows and generally make things look, for lack of a better word, crazy. I want to implement a cancel button that will stop the process from running, but I cannot seem to get the window to stay on top. How do I do this in C#? E...

How to move a directory in C# .NET in a single atomic operation

I need to be able to move an entire directory in a single atomic operation, guaranteeing that nothing else on the system will be able to subvert the operation by creating new files after I start, having a lock on a file, etc. Presumably, I would use System.IO.Directory.Move() if the directories were on the same volume (if Directory.GetD...

Strange .NET Regex Issue

Given the following RegEx expression, testing this on regexlib.com with the string "2rocks" produces a 'match'. However, in my .NET application, it's causing the regex validator to throw a validation error. ^(?=.*[A-Za-z])[a-zA-Z0-9@\-_\+\.]{6,32}$ If I change the string to "rocks2" in both my application and regexlib.com, I get a mat...

Setting WPF nested control properties from the parent control

I have a WPF window, with multiple ListBox controls on it, all sharing the same style that I've simplified here: <Style x:Key="listBox" TargetType="{x:Type ListBox}"> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <Border BorderBrush="Black"> ...