Browse by Tags
All Tags »
Framework 3.5 »
C# (
RSS)
A good way for passing data with EventArgs public class EventArgs <TValue1> : EventArgs { public TValue1 Value1 { get ; set ; } public EventArgs(TValue1 value1) { Value1 = value1; } } Should you want to pass 2 values public class EventArgs <TValue1, TValue2> : EventArgs <TValue1> { public TValue2 Value2 { get ; set ; } public EventArgs(TValue1 value1, TValue2 value2) : base (value1) { Value2 = value2; } } The same goes to CancelEventArgs public class CancelEventArgs <TValue1>...
A convenient solution to get value from IDataReader field. /// <summary> /// Gets the reader field value. /// </summary> /// <typeparam name="TField"> The type of the field. </typeparam> /// <param name="reader"> The reader. </param> /// <param name="fieldName"> Name of the field. </param> /// <returns></returns> public static TField GetValue<TField>( this IDataReader reader, string fieldName) { //Guard...
LINQ is for queries, no doubt about it. Yet - we can do some interesting thins with LINQ, and not just queries. For example, we all deal sometimes with legacy code inherited from some old project - so here some interesting ways to handle this code with few simple lambda expressions. For this example, I will use this Employee class: public class Employee { public Employee( string firstName) { this ._firstName = firstName; } private int _id; private string _firstName; private string _lastName; public...
How do we know which binding to use and when? How do we know which security schema goes with our selected binding configuration? There's allot of considerations with the binding configuration: Is there IIS involved. Are we going to use IIS Integrated Security. Are we going to use net.tcp binding? There's also security issues we need to address: How we going to secure our services communication. Do we use the transport or the message layer. Setting Features Transport Server...
One can only wish everybody to speak LINQ! The following solution demonstrate how to query database tables with object relational data classes. For this example you need to download and install the AdventureWorks Database provided by Microsoft. First, create a new console project: Open the "Server Explorer", click on the "Connect to Database" button: Select the Microsoft SQL Server: The next step is to connect to your AdventureWorks Database Server, from the "Add Connection"...