.net

linq select items from child collection

Below is my calsses. I have a product that contains list of days. Each day has a city property. I need to create a linq query that will give me the distinct cities that are used on all my products in the system. I tried something like this but does not work; var cities = from product in NHibernateSession.Linq<Product>() select new { c...

How to generate method stubs automatically in VS 2008 or using Coderush Express?

Recently I implemented an interface which had some 130 members that i should implement (C#, but i think thats irrelevant). How can i generate the stubs for all those automatically, in VS 2008 Edit:If its not possible in VS 2008, i've also installed Coderush Express, can some one guide me on how to do that with CR Express ? ...

Strange behaviour of code in WPF (rendering issue)

I a WPF application I have the following event-handler of a button-click in a code-behind file of a window: private void AddNewRecBtn_Click(object sender, RoutedEventArgs e) { DimRec.Visibility = System.Windows.Visibility.Visible; PrBarLayer.Visibility = System.Windows.Visibility.Visible; try ...

Is Silverlight able to change a file on a local user's computer?

I considering writing an application in C#/.NET that will programmatically alter an XML file on a user's computer and I trying to determine if Silverlight (and which versions, in what modes) will work for this task. Here's the workflow: User selects file Application modifies file Application saves file, overwriting original file Is ...

ASP.NET - SQLDataSource - FilterExpression - Problem with Empty Strings

In this test application, I am filtering by two ControlParameters. As you can see in the first codeblock, both parameters have a default value of %. This code works great. However, in the second code block, please note that the Default Values are eliminated. The second code block works as long as neither Textbox's text is blank. For some...

A PHP web developer comfortable with C# .NET wants to learn ASP.NET but confused with ASP.NET MVC & Webforms

I'm a decent level PHP web programmer with enough real world experience. I'm also a decent level C#.NET developer. So, I don't want to learn the basics of web development. I also don't have to learn C#. Now I want to start with ASP.NET. I don't know even a,b,c's of ASP.NET. I mean don't even know things like what do I need to setup for ...

Automatically making Base Constructors available in derived class?

I have a Base Class with two constructors, requiring a parameter: public abstract class StoreBase { private readonly SomeObject_sobj; protected StoreBase(SomeObject sobj) { _sobj = sobj; } protected StoreBase(OtherObject oobj) { _sobj = new SomeObject(oobj); } } Then I have a derived clas...

Maximum queued elements in ThreadPool.QueueUserWorkItem

I set the max thread to 10. Then I added 22000 task using ThreadPool.QueueUserWorkItem. It is very likely that not all the 22000 task was completed after running the program. Is there a limitation how many task can be queued for avaiable threads? ...

SQL server timeout 2000 from C# .NET

I have run into a strange problem using SQL Server 2000 and two linked server. For two years now our solution has run without a hitch, but suddenly yesterday a query synchronizing data from one of the databases to the other started timing out. I connect to a server in the production network, which is linked to a server containing order...

Data binding fails when changing numbers on numericUpDown

Hi. I have a databinding like this: numericUpDown1.DataBindings.Add("Value", myBox1, "Width"); Whenever myBox1.Width changes it will update numericUpDown1.Value. The problem is when entering new numbers on the control, myBox1.Width will not be updated immediately, but only after the cursor leaves the text area of the control. Is...

What Exception Type to throw for strings

If I've got the following, really for any string where you check IsNullOrEmpty and it turns up empty, what kind of exception type should one throw, and it's not a argument to a method? I always have a hard time picking exception types because there are so damn many of them. And this is just grabbing a value from the web.config and chec...

Error using Icon.ExtractAssociatedIcon

I'm attempting to load an icon based on a selected file: Icon iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(filename); When I run this code locally through VS, everything works fine. However, after I deploy/install the application that contains this code, I get an error message: "[My Program] - Unable to locate Component: ...

How to restore path with spaces in Windows ?

Hi, I added a key to the registry such that when I right click on a jpeg file I see a new "Transform" option that actually runs my application. My application gets the full path of the selected file as an agrument (in "args" parameter of "Main()"). The problem is that Windows converts the full path of the file to something that contains...

I want "(int)null" to return me 0.

How can i get 0 as integer value from (int)null. EDIT 1: I want to create a function that will return me default values for null representation in their respective datatypes. EDIT 2: How can i work in this scenario for using default. (int)Value Where Value can be null or any integer value. I dont know datatype of value at run time. B...

Separation of concerns - DAO, DTO, and BO

So I have a DAO, DTO, and BO. The following code is the result: // Instantiate a new user repository. UserRepository rep = new UserRepository(); // Retrieve user by ID (returns DTO) and convert to business object. User user = rep.GetById(32).ToBusiness<User>(); // Perform business logic. user.ResetPassword(); user.OtherBusinessLogic(...

Model for Maintaining Collection Over Multiple Threads

I have a shared instance of a List that gets updated randomly by various threads (objects are only added to it via the threads). I then have a timer that executes on a set interval which removes records from the List based on a set of criteria--specifically, if the records are older than x minutes. What I am finding is that as my system ...

Can .NET datatable visualizer be launched from code?

I have several datatable/dataset visualizers installed in my Visual Studio 2008. Launching a visualizer manually in the IDE is a bit time consuming. While debugging, I would like to display a datatable visualizer with a datatable's data automatically through code. I want to put a breakpoint on the line after invoking the visualizer. I k...

How to change System.Windows.Forms.ToolStripButton highlight/background color when checked?

Hi guys, I have a ToolStripButton that is used as a radio button. When it is checked, a blue outline surrounds the button, but there is no background color. It is not clear enough for the user that the button is checked, so I would like to change the background color to make the check state more visible. How do I go about changing the ...

Why does my CLR function keep disappearing

Hi there. I am a rookie to SQL and here is my questions. I have some CLR sql functions and procedures. When I deploy the 1st one, everything is fine. But after the 2nd one deployed, the first one will disappear. Anyone can help me out? Thanks a lot Actually, I simply create a new SQL project in VS, adding a new function or stored ...

MVVM With EF, DataAccess design question

Hi all, First and foremost. Sorry about my English, i'm still learning :) I'm currently wrestling with the MVVM model. At the bottom, i have a database. On top of that sits my DAL which is bascily the ADO.NET entity framework. *Note that the different entities are also my business objects (since i include validation in them). On to...