/// <summary>
        /// Creates an instance of the EntityType object and set the CurrentObject property.
        /// </summary>
        /// <param name="ctx">The CoreDbContext database instance.</param>
        public void ActivateInstance <T>(CoreDbContext ctx) where T : class
        {
            T detailObject = null;

            if (typeof(T).ImplementsInterface <IEntity>())
            {
                if (ViewType?.ToLower() == "single")
                {
                    if (!string.IsNullOrEmpty(Entity.FromSql))
                    {
                        detailObject = ctx.Set <T>().FromSql(Entity.FromSql).FirstOrDefault();
                    }
                    else
                    {
                        detailObject = ctx.Set <T>().FirstOrDefault();
                    }

                    if (detailObject == null)
                    {
                        detailObject = ctx.CreateProxy <T>();
                    }
                }
                else
                {
                    detailObject = ctx.CreateProxy <T>();
                }
            }
            else if (typeof(T).ImplementsInterface <IEntity>())
            {
                if (!string.IsNullOrEmpty(Entity.FromSql))
                {
                    detailObject = ctx.Set <T>().FromSql(Entity.FromSql).FirstOrDefault();
                }
                else
                {
                    throw new ApplicationException($"The DetailView \"{ViewId}\" has an entity \"{Entity}\" that implements the IQuery interface and is mandatory inform the attribute FromSql in Entity definition.");
                }
            }
            else
            {
                detailObject = (T)typeof(T).Assembly.CreateInstance(typeof(T).FullName);
            }

            CurrentObject = detailObject;
        }