Wednesday, 18 September 2013

Updated way to include Kendo dependencies

Hello everyone, 
After spending some time doing performance testing on the MVC project it occurred to me that the quantity of data being downloaded on every request is extremely high. The reason behind this is mainly the Kendo scripts and CSS stylesheets. They were simply placed on the master layout (by me, yes, shame on me I know)​ therefore they were being loaded on every request. This is really not-so-bad since such data are being cached client-side and then retrieved from the cache, still it causes really bad performace on the first load and above all, makes the website displeasant to devices using mobile traffic.

Cascading Deletions Through Code

ModelLet´s say that you do not want to use the database way, that you have a good reason to implement cascading deletions in your code only (maybe because you have no access to the database). In this case, you need to manually remove the related entities of the object under deletion.
Let´s take the Specifications´model. The predefined relations are shown in the picture, yet, cascading has not been enabled for deletions in the SQL server for the corresponding relations. Then, you need to make sure that, when removing a specification, all its SpecificationHeaders have been removed first. Of course, each and every SpecificationHeader must have been cleared off its SpecificationItems prior to its own removal.

Here is some code to do that:

Cascading Deletions in Entity Framework

Model_thumb6Imagine that there is the model shown on the picture. You want to delete an entity of type “Specification”. There is an option called “Cascading” that can be defined under the corresponding relation between two database entries. When Cascading is on, all you need to do is simply delete the parent object. Cascading takes care of the rest, which means that it automatically clears out all related child objects.
The code that is needed comes below:


Thursday, 8 August 2013

Control your wall lights with raspberry Pi

Hello again, it´s been a while. I have decided to move on from Openelec and installed xBian on my Raspberry Pi. It all went smoothly and super fast and I am pretty happy with how it works. The reason for this decision was that Openelec has a read only file system… and I love tampering. I found a nice german guy that described a way to create a very cheap electronic expansion board and bundle it with a raspberry pi to effectively manage to control equipment such as this or this or even this. Wanna see how it`s done? Read on!

Friday, 31 May 2013

Tasker and XBMC, part 2: Create smart playlists and play them by using voice commands (UPDATED!)

Hello again everyone. I assume that you have read the previous post and will try to set up another magic trick with this one here. I will show you how to use your voice, talk to your phone and make XBMC create a playlist based on your command and actually start playing it.

Possible voice commands are for example: "Play music where album is Hairspray" or "Play music where genre is rock" or even "Play music where artist like Jason"
(Of course you need to have those in your music library, right?)

A prerequisite for all these to work is that your android phone and XBMC are connected to the same wireless network.