this is my first post here and I'm also new to C# / OO and LinqPAD. (translate to: I may mis-use concepts or terms due to being in 'learning mode')
I have an application that I've narrowed my bug down to the following query. I decided to try out LinqPAD to solve the issue in a constrained environment.
We are using Entity Framework for our database interactions. I am using LinqPAD's "C# Program" selection.
I found a great tutorial on how to use entities in LinqPAD and this seems to be working. (Proof: 'aEntities' does not return an error like it did when the entities were not connected properly)
So let's get to the issue.
At the 'var' I get: "NullReferenceException: Object reference not set to an instance of an object."
The reason I'm here asking this is every single example I see out there uses this 'var' approach. It does not work for some reason. I've tried declaring 'qryDC', creating a new instance of it and then assigning it. (I'm feeling weak knowledge wise here, but am reading and learning.)
I have read John Saunders epic write up about this topic. (Wow man! Thanks!) What is a NullReferenceException, and how do I fix it?
I however was not able to translate that knowledge to address my issue (learning curve).
Here is the code:
void Main(AEntities aEntities)
{
  decimal fmProjectUID = 1123;
  var qryDC = 
        from pnp in aEntities.PNonPRs 
            from p in aEntities.Projects
            from pt in aEntities.PurchaseTypes
            from wbs in aEntities.P32
            from pc in aEntities.PPhases
            where pnp.ProjectUID == p.ProjectUID
            where p.ProjectUID == fmProjectUID
            where pnp.PurchaseTypeUID == pt.PurchaseTypeUID
            where pnp.P32UID == wbs.P32UID
            where pt.IsNonPR == 1
            orderby pt.PurchaseTypeID
            select new 
            {
                PNonPrUID = pnp.PNonPrUID
                ,PurchaseTypeID = pt.PurchaseTypeID
                ,PhaseCode = pnp.ProjectPhase.PhaseCode
                ,DANbr = pnp.AType.DANbr
                ,PreAmt = pnp.PreAmt
                ,POStDate = pnp.POStDate
                ,POFDate = pnp.POFDate
                ,BaseAmt = pnp.BaseAmt
                ,Notes = pnp.Notes
        ,ChangedByName = pnp.ChangedByName
            };
 }
Let me know if you need more info.
And thank you for your time, effort and thoughts.
 
     
    