I know you can view the NHibernate generated SQL by hooking it up to log4net or piping it out to the console ("show_sql" option), but is there any way to obtain the generated SQL in code at runtime?
What I would like to be able to do is take an ICriteria object (or IQuery) and dump the generated SQL to the screen or custom log (not log4...
I have a List<T1> of items and a second List<T2> of items. Both lists are sorted alphabetically by the property A. I know that the list of items in List<T2> are a subset of List<T1> and no items in List<T2> exists that don't exist in List<T1>.
I need to iterate through List<T1> and change a variable every time it matches a variable ...
I am given:
A class "T" which implements properties that are decorated with Attributes that I am interested in.
A PropertyInfo "p" representing a property belonging to (1) an interface "I" that T implements, (2) a base class "B" that T inherits from, or (3) the class T itself.
I need to get the Attributes defined on (or inherited by)...
I'm creating a simple .NET console application where I want to save a file in a folder that's part of the root project, like so: SolutionName.ProjectName\TestData\. I want to put test.xml into the TestData folder. However, when I go to save my XDocument, it saves it to SolutionName.ProjectName\bin\x86\Debug Console\test.xml.
What do I...
The Excel 2003 API has a GetSaveAsFilename method that pops up the Save As dialog. This takes in various parameters, including the file type (xls, txt, csv,...), something like the following:
GetSaveAsFilename(Missing.Value,
"Microsoft Office Excel Workbook (*.xls), *.xls",
1,
Missi...
Hi,
I was reading about this scenario where making use of the C# using statement can cause problems. Exceptions thrown within the scope of the using block can be lost if the Dispose function called at the end of the using statement was to throw an exception also. This highlights that care should be taken in certain cases when deciding w...
I'm interfacing with a native 3rd party C++ DLL via C# and the provided interop layer looks like below:
C#:
[DllImport("csvcomm.dll")]
public static extern int CSVC_ValidateCertificate(byte[] certDER, int length);
C++:
CSVC_Status_t CSVCOMM_API CSVC_ValidateCertificate(BYTE* certDER, DWORD length,
DWORD context = CONTEXT_DEFAUL...
Is there a way to do something like this in c#? Consider the following example and assume that Child1, Child2, Child3 are all children of Parent -
class Class1
{
SomeObject< Parent > mSomeObject;
Class1()
{
if (condition1)
mSomeObject = new SomeObject<Child1>();
else if (condition2)
mSomeObje...
My company has a C# asp.net application deployed with IIS 7.0.
The location the app is deployed in is
C:\inetpub\wwwroot\my.domain.www\
Under that we have a storage folder which is where we hold temporary files. This folder needs to be writable with each deployment. We reference this folder from within our Web.conf file, and thus the e...
Other than setting a debug variable and incrementing it every time you start the foreach, when you break in with the visual studio debugger connected, is there any way to tell that this is the Xth time through the loop?
I guess this would be a feature of visual studio if anything, not something that would be added to the compiled code....
Possible Duplicate:
String concatenation vs String Builder. Performance
Any difference (performance and memory usage) between the following two options?
option 1:
StringBuilder msgEntry = new StringBuilder();
msgEntry.AppendLine("<" + timeTag + ">" + timeStamp + "</" + timeTag + ">");
options 2:
StringBuilder msgEntry = n...
Suppose I have an array or any other collection for that matter in class and a property which returns it like following:
public class Foo
{
public IList<Bar> Bars{get;set;}
}
Now, may I write anything like this:
public Bar Bar[int index]
{
get
{
//usual null and length check on Bars omitted for calarity
re...
I am trying to loop through all files and folders and perform an action on all files that have a certain extension. This method works fine, but I would like to make it multithreaded because when done over tens of thousands of files, it is really slow and I would imaging using multithreading would speed things up. I am just unsure about h...
For examples sake, lets say I have a table containing these columns
ID (primary key, auto increment)
FirstName (32 characters)
LastName (32 characters)
Picture (binary JPEG data containing on average 10k of data)
Using SubSonic and/or LINQ how can I update only the FirstName column of a record and not try to get the Picture column or...
Hi,
I have DataGrid and I have a hyperlink field but I want to send some information with this link by using URLwriting. I have tried this, but it's not working. So, please help me out.
~/Logout.aspx?ID="row.Cells(1).Text"
I want to send the value of data grid's column but I am getting "row.Cells.Text" instead of receiving the value ...
Just wondering if anyone knows of an open source .Net library that handles dates similarly to the date.js library which allows you to do things like the following.
// What date is next thursday?
Date.today().next().thursday();
// Add 3 days to Today
Date.today().add(3).days();
// Is today Friday?
Date.today().is().friday();
// Number...
I have a Windows Service written in C#. It includes a standalone console mode as well, for debugging purposes. It works fine on almost every computer it's been run on, but we ran into a situation where this service locks up when you try to start it, and then it gets killed because of timeout. But when running it in console mode on the...
Is there any specific example/instance of DI being applied as an architectural principle or design pattern in the .NET Framework itself? Do any (or many) of the types in the framework/BCL conform to IoC?
The type names and a brief illustration/explanation based in C# would be great!
This would compund the need for DI infused design...
I'm writing an app where I want to compare two strings' size. By size, I mean the disk space they would take up if they were directly saved to the disk.
Is it possible to calculate the size of a string in C# without saving it to disk and checking the file information (unless it is more efficient to save it to disk)?
...
I'm looking for .NET static code analysis tools that can detect things like unit tests without an assert, too many asserts in one test, and other anomalies.
...