.net

Fluent NHibernate Mapping a column against one of two columns

I'm dealing with some legacy vendor code that I can't modify. I'd like to wrap the database with an abstraction layer that is easier to use. Given the following two tables, I need to create a mapping for Process.Route that will find the matching Route for a given Process, but that can be either dbo.Route.SourceProcessID or dbo.Route.De...

Is it possible to map a composite key in fluent nhibernate where half of the key is an identity field in the database?

As the question states, is it possible to map a composite key in fluent nhibernate (or non fluent i suppose) where one of the two fields used in the composite is an identity field? I have a table where one part of the primary key is an identity field and the other is a tenant id. This is a legacy database where the composite key is used...

Create an 'iPhone style icon' effect on a thumbnail image?

Hello all, I have an image upload facility in my asp.net project, when uploaded a thumbnail of the image is generated and saved to disk. What I would ideally like to do is apply some nice styling effects to this thumbnail image.. similar to the look of the icons on an iPhone.. perhaps a slight gradient, smooth rounded corners, and a bo...

JavaScript: Format number/currency w/regards to culture like .NET's String.Format()?

This seems like a problem someone would've already solved in the year 2009, but I can't find a decent JavaScript library that will take a number like: 12345.58 And format it correctly based on a specific culture (ie, "nl-nl") or ISO currency code. dojo showed promise, but it doesn't include many cultures by default, and actually wasn'...

Winforms data binding for TextBox

I have a basic property that stores an object of type Fruit: Fruit food; public Fruit Food { get {return this.food;} set { this.food= value; this.RefreshDataBindings(); } } public void RefreshDataBindings() { this.textBox.DataBindings.Clear(); this.textBox.DataBindings.Add("Text", this.Food, "Name"); }...

Run Time Object Graph Builder Composition Library

I am working on a project and have started to use IOC/DI (Unity) and I've looked into MEF. I have come across something which is related to IOC/DI and could probably reuse many of the components that IOC/DI containers use but which isn't the same. This scenario is close to what MEF is trying to accomplish, but rather than assume that f...

How to pass Generic Type parameter to lambda expression?

I have a lambda expression which accepts, a int? (nullable integer), which returns value if value exists or DBNull.Value otherwise. Func<int?, object> getId = id => id.HasValue ? id.Value : (object)DBNull.Value; The goal here is that, I want to make that expression slightly a bit more generic so that I can pass any nullable types lik...

Data in Sql Server should use Unicode?

I want to store English, French, German, Italian, and Spanish in a Sql Server 2005 database to be used with a .NET application. Can I get away with not using Unicode? Will there be any issues with these languages? ...

Why do I have to use "this" to call an extension method from within the extended class?

I've written dozens of extension methods and they all work as expected. But this is the first time I ran into using an extension method in this context. public static class ControllerExtensions { public static RedirectToRouteResult RedirectToAction<TController>( this Controller controller , Expression<Action<TContro...

How can I get a directory from a Uri

For emample, if I have http://www.mysite.com/mydirectory/myfile.aspx How can I get http://www.mysite.com/mydirectory I am looking for a .NET function call. ...

My program crashes when GC perform garbage collection

My program has a trouble: When GC perform garbage collection,my program always crashes at a function,which is called by main flow several times before crashing and the first line of this function is GC.Collect().The function main action is sending some bytes to serial port and receiving some bytes from the same serial port( Both send...

Why System.Net.HttpListener creates a new process?

Why the HttpListener class creates a new web server process, instead of use the normal Socket and a HTTP implementation? ...

Small, editable table of strings. Which Forms control do I want? (.NET)

I have a small array of structs, each struct has three fields, all strings. I want to display these structs in a grid, let the user edit the strings a la Excel, and then retrieve the edited strings of course. Which WinForms control is best for this? Tried a DataGridView but setting the DataSource to the array of structs doesn't seem to ...

Cannot get data in MS Access database

Hi all, I have an Access database stored on PC A, and an application located on PC B and C. When the application loads the data from the database, the error message "The Microsoft Jet database engine cannot open the file '\xxx.xxx.xxx.xxx\FolderName\Test.mdb'. It is already opened exclusively by another user, or you need permission to...

IE not detecting proxy server hosted on a VM

Hi guys, I was writing a proxy server in C#.NET. My Proxy server has been hosted on a VM (say vm1). Now when I access internet through IE in vm1 the request goes through the proxy server as expected. But if I use another VM say vm2 to access internet through IE the 'Internet Explorer cannot display the webpage' is displayed. I checked t...

Comparing and Merging Identical columns of two Datatables

Hi, I have two datatables.There are few identical columns in both of them.Now I need to compare each Identical column's cell in both the datatables and build a third datatable by merging the changes of identical column's cells and also the un-identical columns.Please help me with C# code in doing it. Thanks, Vix ...

.NET - I want to do this: Dim D as new Dictionary(of String, Array(OF MYOBJECT))

I'd like to create a Dictionary that is indexed by Strings: Dictionary(of String, ...) I'd like the Type after the comma to be an Array of MyObject's. If all I do is the following: Dim D as new Dictionary(of String, Array) I feel like I'm missing out on some performance very time I access a member: Dim Object1 as MyObject = MyDict...

.net XML Serialization - Storing Reference instead of Object Copy

In .Net/C# Application, I have data structures which have references to each other. When I serialize them, .Net Serializes all references with separate object copies. In Following Example, I am trying to serialize to Array of 'Person' A 'Person' may have reference to another person. public class Person { public string Name; pub...

Looking for a simple ASP.Net web site sample

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 + ADO.Net + ASP.Net + SQL Server 2008 Enterprise + IIS 7.0. I want to save my time to write an simple ASP.Net web site. And want to see if I can find an available one here. :-) What I need is very simple, (1) basic UI (2) could edit/update/delete data from database (any kinds of data...

How to start the application directly in system tray? (.NET C#)

I mean when the user starts my application(exe). I want it to start directly in system tray, without showing the window. Like antivirus softwares & download managers, which start and run in the system tray silently. I want the same effect and when user click the "show" button of the notifyIcon's contextmenustrip then only application sh...