I have one function that requires an active dbContext that is used in multiple places. In some places the DbContext already exists so I pass it in and use it if it does: public void DoStuff(){ using (var db = new dbContext()){ DoThings(db); db.SaveCh
Is there a way to compare discriminated unions by their case-identifiers in F#? type MyUnion = | MyString of string | MyInt of int let x = MyString("hello") let y = MyString("bye") let z = MyInt(25) let compareCases a b = // compareCas
I am attempting a LINQ query in a VB.NET WPF solution that bridges two datatables and groups by a Zone. I am receiving an "Invalid Cast Exception" on these rows: .MfstCt = ZoneGroup.Count(Function(c) c.Field(Of String)("ConsignmentNumber&qu
I looking for a way to search and remove node by a name. I have XML for example and I want to remove node <aRemove> I tried using : xmlDoc.SelectNodes("//aRemove"); xmlDoc.SelectNodes(".//aRemove"); xmlDoc.SelectNodes("a aRe
I am reading a XMl and using it for some processing in my application. var config = XElement.Load("c:/sample.xml"); Is there anyway to do load it in a better way? it takes a while while trying to process this line of code.Look at XmlReader class
I'm working on a project where I had to add a data layer to my application. I've always thought that the data layer is purely responsible for CRUD functions ie. shouldn't really contain any logic but should simply retrieve data for the business layer
This question already has an answer here: Random number generator only generating one random number 7 answers I am using c# to try and populate a datagridview with random numbers but for some reason I keep getting the same value in all the cells. pub
I'm trying to get a node.js app to interact with a .NET SDK fingerprint reader called U.are.U. The SDK provides .dll (win32 and x64), Java and .NET libraries. I decided to use .NET for the simple of use, having all the interfaces ready to use and all
I have a table named as EnrollTrainee. I have these columns in my EnrollTrainee Model Class: [Key] public int id { get; set; } public int TraineeID { get; set; } public int TrainerID { ![enter image description here][1]get; set; } public virtual Crea
I'm trying to get the IoC concept down with a winforms app. Say I have a presenter whose constructor takes its view and a service as constructor arguments. So in the form code I have something that amounts to this: mnPresenter = new Presenter(this, n
I have 2 forms.. from first form i call 2nd form... in second form i do some calculations and i want to get the result in first form after closing second form. First Form Code public partial class XtraForm1 : DevExpress.XtraEditors.XtraForm { String
I would like to divide a worksheet into multiple files. I have a worksheet with about 10,000 rows. there is fancy formatting, conditional formatting, nice colors, and I want to preserve all of these attributes. I need to divide this worksheet up. the
I have an application behaving like autorefresh. It checks emails, new videos, jokes, etc. My client wants these single elements check in different intervals. For example emails every minute, videos every hour, etc. So there should be option for him
Does anyone know why covariant return types are not supported in C#? Even when attempting to use an interface, the compiler complains that it is not allowed. See the following example. class Order { private Guid? _id; private String _productName; pri
I have two aspx page on my application. From the first one, lets say default.aspx, I have one button and one textbox. When I click the button I do an ajax call to the checkname.aspx as below function docheck() { var un = $('#username').val(); $.ajax(
Possible Duplicate: How can I convert an integer into its verbal representation? I am looking for some solution to return a number as text. By that I mean that 100 should be returned as 'one hundred' It is more or less just a tidious task to make suc
I was trying to hit a web service using the instructions here: http://help.seeclickfix.com/kb/api/creating-an-issue I came up with the code below: string paramContent = "api_key=afs684eas3ef86saef78s68aef68sae&issue[summary]=abeTest&issue[lat
I need to get the position of the mouse on click in a form, and save the x and y coordinates. I made this simple function: public void kokot (MouseEventArgs e) { x = e.X; y = e.Y; this.Invalidate(); } How can I call it? When I try kokot() it doesn't
I am developing a .NET 4.0 client that will utilize a C Library for data processing. The user will be able to specify the DLL file they wish to load for processing. I am doing late binding / assembly loading as described here. http://blogs.msdn.com/b
I am using XPath to exclude certain nodes within a menu. I want to expand on this to exclude nodes identified within an array. This works to exclude all the nodes in the menu with id 2905 whose type is not content: XmlNodeList nextLevelNodeList = cur
Ok so it appears in the .NET framework API docs that the CommandArgument property of the CommandEventArg class is of type 'object' suggesting that I might assign to it something other than a string object yet I get an InvalidCastException using the c
string data = "0000062456" how to split this string on 5 pieces so that I have: part[0] = "00"; part[1] = "00"; part[2] = "06"; part[3] = "24"; part[4] = "56"; Use Substring(int32, int32): part[0
I'd like to run some NUnit unit tests against a class in a .Net class library assembly which is designed to be hosted by an external process (outside of my control) and loaded at runtime. The class I want to test derives from a class defined within t
There is an IP web camera that I wrote a .NET class for sometime ago. It's basically a Timer implementation that pings a snapshot CGI script from the camera every five seconds. The camera itself is very rudamentary; it does not have any sort of API f
How can you make WCF use xs:All instead of xs:Sequence when it defines complex object types in the wsdl/xsd for a web service? The issue I am having is that xs:Sequence requires that calling applications pass the elements in the soap message in the o
I'm fooling around with the XNA framework. To help me around I made a helper class that looks like this: ActorHolder + SpriteBatch (SpriteBatch) + ContentManager (ContentManager) - drawables (IList<IDrawable>) - updatables (IList<IUpdatable>)
How can I make a Property "ReadOnly" outside the Assembly (DLL) for people using the DLL but still be able to populate that property from within the assembly for them to read? For example, if I have a Transaction object that needs to populate a
How can I make my window not have a title bar but appear in the task bar with some descriptive text? If you set the Form's .Text property then .net gives it a title bar, which I don't want. this.ControlBox = false; this.FormBorderStyle = System.Windo
I want to recreate the stickiness and snapping of windows, like it is implemented in Winamp. The basic premise is, when you drag a window and it comes close to another one, it will snap to it and will stick. When you move it the two will move togethe
When debugging in Visual Studio, sometimes I add a breakpoint but it's hollow and VS says "The breakpoint will not currently be hit. The source code is different from the original version." Obviously this prevents me from being able to debug. Wh