Blog Archives
WinDays13 – kratki utisci, pptx datoteka i demo primjeri
Još uvijek traje jedna od najvecih Microsoft konferencija u regionu, i nakon dva dana konferencije mogu reći da su ovi WinDaysi do sada najbolje organizirana konferencija. Preko 1000 registrovanih polaznika i stotinjak predavača samo su neke od statističkih brojki ove konferencije.
Da je ovo prava developerska konferencija između ostalog možemo se uvjeriti na dobroj posjećenosti dev predavanja. Prvog dana konferencije najzanimljiviji dijelovi možemo kazati da su bili ITPro i Dev keynote , a posebno je interesantnan bio keynote od Damir Dobrića koji je zbog štrajka radnika avio-kompanije, javljanje održao preko Skypea sa ljubljnskog aerodroma. Drugog dana nastavilo se u dobrom raspoloženju, a sada već tradicionalna večera predavača desila se u restoranu nedalok od konferencije u pravom istarskom stilu.
Drugog dana konferencije održao sam predavanje na temu MVVM u razvoju WP8 i Windos store aplikacija, i sa zadovoljstvo mogu reći da je proteklo u dobroj atmosferi sa prepunom salom. Kao što sam najavio prethodno moje predavanje oko MVVM tehnike na WP8 i WinRT bilo je drugog dana konferencije. Ovim pute se zahvaljujem svim posjetiocima predavanja i kao što sa obećao demo primjere i prezentacijku datoteku objavljujem na kraju posta.
Oktobarski sastanak Bihac .NET UG
Termin sastanka: 31. 10. 2012. 17:00, Tehnički fakultet Bihać
Nakon ljetnje pauze i septembaskih obaveza zakazujemo naredni sastanak Bihac .NET UG. Naime, u srijedu 31. oktobra sastaćemo se na starom mjestu, na Tehničkom fakultetu u Bihaću i održati sastanak na temu razvoja Windows 8 aplikacija. Ovog puta moja malenkost će održati predavanje pod nazivom “Consuming data in Windows 8 Store apps” u narednom tekstu date su detaljne informacije o predavanju.
Tema: Consuming data in Windows 8 Store app / Konzumacija podataka u Windows 8 Store aplikacijama
Level: 300
Predavač: Bahrudin Hrnjica, Microsoft MVP
Opis: Windows 8 Store aplikacije izvršavaju se u izoliranom okruženju kojim upravlja Windows Run-Time. Ova okolina pruža mogućnosti razvoja aplikacija pod nazivom Windows Store app, odnosno novi tip aplikacija koje se vrte na Windows 8 OS. Jedna od karakteristika ovih aplikacija je što su prilagođene za pokretanje na raznim uređajima od notebooka, tableta do PCa, i što mogu da se distribuiraju na Windows Store globalnu prodavnicu Windows 8 aplikacija. Jednistvenost platforme daje i određena ograničenja, a u ovom predavanju ćemo vidjeti na koji način Windows Store aplikacijama obezbijediti podatke iz različitih izvora podataka, a posebno sa SQL Servera. Widnows Store aplikacija nisu u mogućnosti da direktno pristupe Entity Framework ORM maperima, pa smo prisiljeni da koristimo ili ASP.NET Web API ili WCF. Demo primjeri će pokazati kako koristiti HTTPClient klasu za pristup podacima preko pomenutih serverskih tehnolgija. S druge strane na predavanju će biti pokazano kako koristiti SQLite C++-cross-platform biblioteku u Windows Store applikacijama direktno bez korištenja pomenutih Rest i WCF tehnologije. Kroz demo primjere predavanje će dati kompletnu sliku kako Windows Store aplikacija mogu koristiti podatke iz vanjskih izvora bez kojih je teško zamisliti današnju modernu Windows 8 Store aplikaciju.
Na sastanku će biti i nekoliko nagrada na najsretnije i najaktivnije članove. Nagrade su: majica, usb stik, …..
Developing Windows Store App Part 1: Database Model
This is the first of several blog posts about developing Windows 8 Store app. The first blog post will show how to implement database model which will be used in our application. If you want to get more information about the application we are developing please see the previous announcment post. Before we start with the tutorial, several requirements must be satisfied:
1. You need to have installed at least Visual Studio 2012 Express
2. You need to have at least SQL Server 2008 or 2012 Express.
Our database model is very simple. We have three tables: Places, Dishes and Towns. Relation of those tables shows the picture below.
SQL database will also be provided by the end of the blog post. Now that we have database model on the paper, we can start with implementation. We will use Entity Framework 5, and Code First technology in order to implement db model.
Start Visual Studio 2012, choose File->New->Project. Choose ClassLibrary similar as picture below.
After we created the empty Class Library project, we can start with implementation of the entities. According to db model shoed earlier, we are going to create three .NET classes: Dish, Town, Place. In order to do that:
- Right Click at the Project
- Add New Class
- Give name: Dish
Repeat the process for Town and Place. Text below shows the implementation of classes.
Town class:
public partial class Town
{
public int? TownID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Image { get; set; }
//relation 0-oo
//many places can be in one Town
public ICollection Places { get; set; }
}
Dish class:
public partial class Dish
{
public int? DishID { get; set; }
public string Name { get; set; }
public string Slogan { get; set; }
public string Description { get; set; }
public string Image { get; set; }
//relation 0-oo
//many places can have one dish
public ICollection<Place> Places { get; set; }
}
Place class:
public partial class Place
{
public int? PlaceID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int? DishID { get; set; }
public string Slogan { get; set; }
public string Type { get; set; }
public int? TownID { get; set; }
public string Image { get; set; }
//one relation to Dish
public Dish PlaceDish { get; set; }
//one relation to Dish
public Town PlaceTown { get; set; }
}
Since we are using Code First, we need to specify the relation between entities too. That’s why we have put the last two properties in Place class, and also IColletion property of the previos classes. This is enough information that Code First make relation between tables on SQL Server. By default PlaceID is primary key for Place table, as well as DishId and TownID for corresponded tables.
Now that we have entities, we need to implement DBContex, central class for handling all operation and transaction against database. Before we implement DBContext we need to add Entity Framework reference. Since EF is separated from the .NET we can use NuGet to accomplish this.
1. Right click on Reference, choose Manage NuGet package
In Search box type: Entity Framework and hit enter. Package will appear in the list. Click Install button. Picture below shows Manage NuGet Package dialog. Accept license agreement, and close the dialog.
CExplorer DataContext class:
public class CExplorerContext: DbContext
{
public CExplorerContext() : base("cexplorer_db")
{
Configuration.LazyLoadingEnabled = false;
}
//entity sets
public DbSet<Place> Places { get; set; }
public DbSet<Dish> Dishes { get; set; }
public DbSet<Town> Towns { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//crating one to many relation between Town and Place
modelBuilder.Entity<Place>()
.HasRequired(x => x.PlaceTown)
.WithMany(d => d.Places)
.WillCascadeOnDelete(true);
////crating one to many relation between Dish and Place
modelBuilder.Entity<Place>()
.HasRequired(x => x.PlaceDish)
.WithMany(d=>d.Places)
.WillCascadeOnDelete(true);
base.OnModelCreating(modelBuilder);
}
}
As you can see, we have overridden ModelCreation virtual method and implement relation between entities. This is classic one to many relation.
At the end of the implementation, we need to provide connection string to SQL Server, it must be with the same name as we specified in the implementation od the DBContext.
1. Add New Item: App.config file and put the following configuration.
Based on SQL instance name, change the connection string. Database could not exist on the SQL server. If there is a database on the SQL with the same name, EF will add table in to existing database.
Before we end the today’s post, lets quickly create Console Test application to make sure we implemented correct model.
1. File->New->Add New Project
2. Console Application

Like previous add Entity Framework by NuGet.
Add reference of EFModel.
Open Program.cs and put the following implementation:
class Program
{
static void Main(string[] args)
{
CExplorerContext ctx = new CExplorerContext();
var dish = new Dish() { DishID = 1, Description = "Description", Name = "DishName", Slogan = "Slogan", Image = "Default.jpg" };
var town= new Town(){TownID=1, Name= "TownName", Description="Description", Image=""};
ctx.Dishes.Add(dish);
ctx.Towns.Add(town);
ctx.SaveChanges();
var place = new Place() { PlaceID = 1, Name = "Place Name", Description = "DEscription", Image = "default.jpg", Slogan = "Slogan title", DishID = 1, TownID = 1 };
ctx.Places.Add(place);
ctx.SaveChanges();
var plc = ctx.Places.FirstOrDefault();
Console.WriteLine("Place from Database");
Console.WriteLine("Place from database Name:{0}", plc.Name);
Console.Read();
}
}
After we run, output console shows that the entities are inserted successively on database.
In other words Cexplorer_DB database is created on the SQL server, and entities are inserted from the test.
Code First approach is very powerful, we only need to specified connection string, and everything is created just like we do, in Model First approach. Complete source code for this Demo can be found here.
MSCommunity BiH Session: Developing Windows Store LOB apps
After great 3 days of KulenDayz and CEE MVP Summit in Baranja (north-east part of Croatia), the next conference I will be speaking is MSCommunity BiH konferencija in Sarajevo.
For the first time, Microsoft Community in Bosnia and Herzegovina is organizing the event dedicated for launching new Microsoft products Windows 8, Windows Server 2012 and Visual Studio 2012. For this conference I prepared a session about developing Windows Store LOB apps. This presentation has a lot of cool demos integrated in to one app called ĆevapExplorer.
Through the session I will be presenting how to design Windows Store app, by describing main design requirements of each WinStore app. Beside design feature, Win Store app requires data and connection to data source. Through the demo it will be presenting how to develop data model by using the latest Microsoft ORM Entity Framework V5.
After DB model is implemented, we need some way to provide data to Windows Store app. Windows Store app is running in some kind of isolated storage provided by Windows Run-Time, so there is no way to connect EF model directly to Win Store app. The only way to provide EF data to Win Store app is by implementing some kind of web service (REST or WCF in our case).
The second part of the demo will be presenting how to implement WCF service by using the latest version of the .NET 4.5 and WCF 4.5. If you want to develop lighter service infrastructure, beside WCF, you can use ASP.NET Web API to implement RES service.
The further demo will be presenting how to implement REST service that will be used by Win Store app. Implementation of REST service by using ASP.NET Web API is very popular MS Technology today, and it is recommended for developing this kind of services.
After backend infrastructure is presented, the main demo can starts using data of EF Model through REST or WCF service. In the first part of the main demo it will be presenting how to develop UI for presenting data, by describing how to use predefined visual studio 2012 templates, how to use HttpClient and how to integrated our app with Windows 8, by implementing Windows 8 contracts. By implementation Search Contract, demo will show how to integrate Windows 8 Search mechanism in to our app.
As the last part of demo, it will be presenting how to implement data source without using .NET infrastructure, but using only WinRT. For this we will use SQLite library. SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. Because of native support of WinRT, this library can be easily compiled and built in Windows RunTime, so we used it as a C/C++ class library in our C# WinStore app. This part of demo present how to used native nature of WinRT to use C/C++ library in our C# application, without complex implementation seen in .NET with P/Invoke and DLL Import.
Because of importance of accepting new Windows 8 develop technology in the future development, this blog post is part of several post which will give detail information about each mentioned part of the demo. Each blog post will be describe in form of tutorial one part of the demo. The name of demo is ĆevapExplorer. Ćevap stands for the most populate Bosnian national dish which can be found in every restaurant, but only few of them serve the best Ćevap. The application is collecting data about the best restaurants around the Bosnia not only for Ćevap, but the main Bosnian dishes. The app present location about restaurants serving the best dish.
After conference event, blog post will be published periodicaly.
See you in Sarajevo.


























