Skip to content

Tag Archives: C#

The null value cannot be assigned to a member with type System.Int64 which is a non-nullable value type

03-Sep-10

Are you getting this? System.InvalidOperationException: The null value cannot be assigned to a member with type System.Int64 which is a non-nullable value type. On something like this? var totalSize = query.Sum(x => x.Size); This occurs because your LINQ property (in my case “Size”) is not nullable, and needs to be nullable because your Sum() operation [...]

.Net Enum Values As Bit Flags

13-Apr-10

Every now and then I find myself needing to set multiple values to an enum object and test this later on, synonymously I usually find myself also scouring the net on the best practice on how to set, access and test these enum flags So today I thought I would post a definitive reference I [...]

.NET Framework/ASP.NET/C# Development Ultimate Learning Resources (Tutorials for Beginners to Advanced)

15-Mar-10

Howdy everyone, firstly I would like to apologise for the lack of blog updates, I have seriously been flat out on development with our new online start-up, Fotochimp and have not had much time for blogging. However today I am taking a few minutes time-out to share some links with you I found for a [...]

How to Add a Collection of a Derived Type/Subclass with Generic List AddRange()

20-Sep-09

Another gem today, when attempting to add a subclass collection to a base type list using the AddRange() method you may encounter the following error using this code: List<BaseClassA> baseList = new List<BaseClassA>(); baseList.AddRange((IEnumerable<SubClassB>) subList); // Where ‘SubClassB’ is a class deriving from ‘BaseClassA’ System.InvalidCastException was unhandled: Message=”Unable to cast object of type ‘System.Collections.Generic.List`1[MyNamespace.BaseClassA]‘ to [...]

My name is Graham O'Neale and I'm a software architect from Gold Coast, Australia. I am an overtime thinker, full time coder and awake part time in the real world. I have a keen interest in software development, particularly in the realm of programming (C#, ASP.NET, ASP.NET MVC, LINQ (2 SQL), Entity Framework, Silverlight, Blend, WCF, WPF) and a keen interest in the cutting edge and innovation. I have a new found love for design patterns, ALT.NET practices and well crafted software architecture. The purpose of this blog is to express any thoughts, findings, tips and gripes along my travels in the wonderful world of coding and technology...