One of the best to graphs diagrams of LINQ I know is in Mastering C# – Lecture Notes Part 2 of 4 – CodeProject [WayBack]
The LINQ explanation in that article [WayBack] is top notch as well. Thanks Florian Rappl [WayBack]!
–jeroen
Posted by jpluimers on 2017/08/17
One of the best to graphs diagrams of LINQ I know is in Mastering C# – Lecture Notes Part 2 of 4 – CodeProject [WayBack]
The LINQ explanation in that article [WayBack] is top notch as well. Thanks Florian Rappl [WayBack]!
–jeroen
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/12/15
Without dsquery installable, I had to query an ActiveDirectory spanning two domains.
Here are some links that helped:
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/09/21
It’s been in the System.Array class forever, but remarkably few people do know that it can throw you a NotSupportedException (for instance when calling Add, Insert, Remove, etc).
It does because it implements IList, but not all methods implemented from IList are valid.
And it also indicates that, as the IList Properties allows for IsFixedSize to return false.
A similar case is there for IsReadOnly: then you cannot even modify the values.
Ever since I started teaching .NET/C# classes almost 15 years ago, I warned:
beware when you use IList as not everybody implements all methods.
–jeroen
via:
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/08/18
Empty arrays are not used often as arrays usually are about the presence data, not about the absence.
Here are two ways based on the int data type in C# (the original [WayBack] examples [WayBack] are using string, but since string itself is also a kind of array…):
Specify a size of zero:
int[] a = new int[0];
Specify an empty initialisation:
int[] a = new int[] { };
Though many people think arrays are a thing of the past, I think it is one of the first generic types and have their place. For one, enumerating over arrays using foreach is a lot faster in many environments than enumerating over other data types. Another thing is that the fixed nature of arrays can be very beneficial in setting constraints.
That’s why I like the balanced view from Eric Lippert [WayBack] in Arrays considered somewhat harmful – Fabulous Adventures In Coding – Site Home – MSDN Blogs [WayBack]
–jeroen
via:
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/07/27
It comes down to these cases for XML elements having maxOccurs="1" (which the default for maxOccurs):
nillable="true" will convert from a regular type to a nullable type.minOccurs="0" will add boolean …Specified properties in the generated C# for each element.nillable="true" and minOccurs="0" in an element which gets you a nullable type and a …Specified property.Note I’m not considering
fixedordefaulthere, norattributes(that haveuseinstead ofminOccurs/maxOccurs, but do not allow for nillable) nor larger values ofmaxOccurs(which both xsd.exe and xsd2code regard asunbounded).
From the above, XML has a richer type system than C#, so in XML there are subtle a differences between:
nil in the XML elementHopefully later more text and examples to show how to actually work with this.
Delphi related to minOccurs:
Note that xsd2code.codeplex.com (unlike XmlGen#) has at least two forks at github:
From the specs:
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Conference Topics, Conferences, Development, Event, Software Development, XML, XML/XSD, XSD | Leave a Comment »
Posted by jpluimers on 2016/07/07
Easy way to generate “System.InvalidOperationException: Nullable object must have a value.”.
| using System; | |
| public class Test | |
| { | |
| public static void Main() | |
| { | |
| int? nullableInt = null; | |
| int nowInt = (int)nullableInt; | |
| } | |
| } |
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2016/06/08
Boy I wish I had known this earlier. Like years ago…
In the Solution Explorer:
It is next to the “Project Dependencies” in this image from Sara Ford:
In the resulting dialog, you can change the build order within your solution.
This can be very useful when – for various reasons – you cannot have Project Level dependencies for an assembly, but have to have Assembly Reference dependencies for individual assemblies.
At a client I bumped into this, and this dialog was a life saver for us.
Others have used it because some Visual Studio versions miscalculate the dependencies.
–jeroen
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development, Visual Studio 11, Visual Studio 2008, Visual Studio 2010, Visual Studio 2012, Visual Studio 2013, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2016/03/22
Even though as of 12c R1, Oracle supports a row limiting clause, NHibernate 4.2 with Oracle.DataAccess.dll 2.112.3.0 does not support that.
When you let it generate the SQL for a LINQ Take call to limit the number of results, you get an exception like this (full exception and stack trace are below):
System.NotSupportedException was unhandled by user code HResult=-2146233067 Message=Specified method is not supported.
The place where you Take is important, as this does fail:
Read the rest of this entry »
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, .NET ORM, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Database Development, Development, NHibernate, OracleDB, Software Development | Leave a Comment »
Posted by jpluimers on 2016/03/17
When you have one app.config for your whole set of DTAP environments (develop/test/acceptance production), every once in a while you get this error:
ORA-12154: TNS:could not resolve the connect identifier specified
For this particular setup, it means the replacement of parameters in the app.config with actual values from the DTAP went wrong (or was missing). For that we’ve some steps in both the PreBuildEvent and PostBuildEvent of the .csproj file:
del "$(ProjectDir)$(TargetFileName).config"
copy "$(ProjectDir)app.config" "$(ProjectDir)$(TargetFileName).config"
powershell -noprofile -file Replace-Parameter.ps1 -Path "$(TargetDir)$(TargetFileName).config"
The PreBuildEvent looks like it is not needed, but sometimes Visual Studio forgets to perform the copy action.
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, .NET ORM, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Database Development, Development, NHibernate, OracleDB, Software Development | Leave a Comment »
Posted by jpluimers on 2016/03/16
It seems I always forget about the InternalsVisibleTo attribute which allows you to specify which external assembly can see your internal types and type members:
Internal classes need to be tested and there is an assembly attribute:
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("MyTests")]Add this to the project info file, e.g. Properties\AssemblyInfo.cs.
Thanks Eric Schaefer for that answer.
–jeroen
via .net – C# “internal” access modifier when doing unit testing – Stack Overflow.
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »