Sunday, November 26, 2017

Tuesday, November 21, 2017

Entity Framework - On Model Creating

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
  //General Remove Pluralizing Table Names
  modelBuilder.Conventions.Remove<PluralizingTableNameConvetion();

//Global
  modelBuilder.Conventions.Remove<DecimalPropertyConvention();
    modelBuilder.Conventions.Add<new DecimalPropertyConvention(5,2));
    //Property Specific:
    modelBuilder.Entity<Student>()
   .Property(cb => cb.Score)
   .HasPrecision(5,2);


  base.OnModelCreating(modelBuilder);
}

Numbers Precision and Scale Reminder

In this Case a Precision of 5 and a scale of 2.

Thursday, November 2, 2017

C# - Assembly Qualified Names Explained.


Syntax:
<appSettings>
<add key="IPersonRepository"
         value="Generics.Repository.PersonRepository.PersonServiceRepository,
                     Generics.Repository, Version= 1.0.0.0, Culture=neutral" />

</appSetting>
Somewhat Explained Syntax:

<add key="IPersonRepository"
         value="{Full namespace name},
                     {The Dll its going to look in}, Version= 1.0.0.0, Culture=neutral" />

</appSetting>

Wednesday, November 1, 2017

C# - CRUD Interface Template

public interface IRepository < T, TKey > {
 IEnumerable < T > GetItems();

 T GetItem(TKey key);

 void AddItem(T newItem);

 void UpdateItem(TKey key, T updatedItem);

 void DeleteItem(TKey key);

 void UpdateItems(IEnumerable < T > updatedItems);
}

Friday, October 6, 2017

EPISERVER - MVC Controller CurrentPage Null ! Sucks massive!

The following code will not work since the the Index name is randomPage instead of currentPage.
This is one really bad design from EpiServer since it's ok MVC pattern but apparently wont hook correctly to episervers architecture.

Wont Work:

public class FlexLandingPageController : PageController<FlexLandingPage>
    {
        public ActionResult Index(FlexLandingPage randomPage)
        {
            var model = new FlexLandingPageViewModel<FlexLandingPage>(randomPage);
            //model will be == Null!
            return View(model);
        }
    }


Will work:

public class FlexLandingPageController : PageController<FlexLandingPage>
    {
        public ActionResult Index(FlexLandingPage currentPage)
        {
            var model = new FlexLandingPageViewModel currentPage)
             //model !=Null
            return View(model);
        }
    }