private void LoadProjectInfo()
        {
            DGV_Project.InvokeIfRequired(dg =>
            {
                dg.Columns.Clear();
                dg.DataSource         = null;
                dg.AllowUserToAddRows = false;
            });

            CB_ProjectList.InvokeIfRequired(cb => _publishedProject = cb.SelectedValue as PublishedProject);
            if (_publishedProject == null)
            {
                return;
            }

            if (Settings.Default.LoadAllProperties)
            {
                LoadQueryFields(_publishedProject.Draft);
            }
            else
            {
                ProjContext.Load(_publishedProject.Draft, p => p, p => p.Tasks, p => p.Assignments, p => p.ProjectResources);
            }
            ProjContext.ExecuteQuery();
            List <PropertyInfo> retrievedFields = DisplayFields(_publishedProject.Draft);
            DataTable           dt = CreateDataTableForDisplay(retrievedFields);

            dt.ExtendedProperties.Add(dt.Rows.Count, _publishedProject.Draft);
            DataRow dr = dt.NewRow();

            retrievedFields.ForEach(prop => SetPropertyValueInDataColumn(dr, prop, _publishedProject.Draft));
            dt.Rows.Add(dr);

            DGV_Project.InvokeIfRequired(dg =>
            {
                dg.DataSource = dt;
                dg.Refresh();
                TP_Tasks.Text       = $"Tasks({_publishedProject.Draft.Tasks.Count()})";
                TP_Assignments.Text = $"Assignments({_publishedProject.Draft.Assignments.Count()})";
                TP_Resources.Text   = $"Resources({_publishedProject.Draft.ProjectResources.Count()})";
                if (_publishedProject.Draft.Tasks.Any())
                {
                    LoadTasksInfo(_publishedProject.Draft.Tasks);
                }
                if (_publishedProject.Draft.Assignments.Any())
                {
                    LoadAssignments(_publishedProject.Draft.Assignments);
                }
                if (_publishedProject.Draft.ProjectResources.Any())
                {
                    LoadProjectResources(_publishedProject.Draft.ProjectResources);
                }
            });
        }
        private void LoadQueryFields <T>(T clientObject) where T : ClientObject
        {
            IOrderedEnumerable <PropertyInfo> props = clientObject.GetType().GetProperties().Where(p =>
                                                                                                   p.ReflectedType.Namespace.Contains("Project") &&
                                                                                                   !_fieldsToExclude.Contains(p.Name)).OrderBy(p => p.Name);

            MethodInfo lambdaMethod = typeof(Expression)
                                      .GetMethods()
                                      .First(x => x.Name.Contains("Lambda") &&
                                             x.IsGenericMethod &&
                                             x.GetParameters().Length == 2 &&
                                             x.GetParameters()[1].ParameterType == typeof(ParameterExpression).MakeArrayType())
                                      .MakeGenericMethod(typeof(Func <T, object>));

            foreach (PropertyInfo prop in props)
            {
                if (IsPrimitiveEquatable(prop.PropertyType))
                {
                    Log.WriteVerbose(new SourceInfo(), "Loading property:{0} of Type:{1}.", prop.Name, prop.PropertyType.Name);
                    Expression <Func <T, object> > expr = GetExpression(clientObject, lambdaMethod, prop);
                    if (expr != null)
                    {
                        ProjContext.Load(clientObject, expr);
                    }
                    else
                    {
                        Log.WriteWarning(new SourceInfo(), "Failed loading property:{0} of Type:{1}.", prop.Name,
                                         prop.PropertyType.Name);
                    }
                }
                else if (prop.PropertyType.IsEnum)
                {
                    Log.WriteVerbose(new SourceInfo(), "Loading Enum:{0} of Type:{1}.", prop.Name, prop.PropertyType.Name);
                    Expression <Func <T, object> > expr = GetExpression(clientObject, lambdaMethod, prop);
                    if (expr != null)
                    {
                        ProjContext.Load(clientObject, expr);
                    }
                    else
                    {
                        Log.WriteWarning(new SourceInfo(), "Failed loading Enum:{0} of Type:{1}.", prop.Name,
                                         prop.PropertyType.Name);
                    }
                }
                else if (prop.PropertyType.IsSubclassOf(typeof(ClientObject)) ||
                         prop.PropertyType.IsSubclassOf(typeof(ClientObjectCollection)))
                {
                    Log.WriteVerbose(new SourceInfo(), "Loading Object:{0} of Type:{1}.", prop.Name,
                                     prop.PropertyType.Name);
                    Expression <Func <T, object> > expr = GetExpression(clientObject, lambdaMethod, prop);
                    if (expr != null)
                    {
                        ProjContext.Load(clientObject, expr);
                    }
                    else
                    {
                        Log.WriteWarning(new SourceInfo(), "Failed loading Object:{0} of Type:{1}.", prop.Name,
                                         prop.PropertyType.Name);
                    }
                }
                else
                {
                    Log.WriteWarning(new SourceInfo(), "Unknown property type {0} for property {1}",
                                     prop.PropertyType.Name, prop.Name);
                }
            }
        }