Author: Dawid

Using InverseProperty and ForeignKey Attributes

InverseProperty and ForeignKey are (arguably) the most commonly used attribues in Entity Framework when developing in code-first approach. They help greatly simply the job of managing our models. Foreign Key In order to introduce foreign key to our code we need to specify to what objects it maps to. So there are two things that

Continue Reading

Removing Entry from a Database using Entity Framework

Most of the tutorials on the internet seem to focus on how to remove these objects from DataContext as opposed to DbContent. However, if your database is built using code first approach you are unlikely to be using DataContext/. In order to delete an entry from the database, firstly Remove the element and then save

Continue Reading

Proper way of returning multiple values from a method

Since C# 7 you can make method signatures which correspond to multiple values In Python, you can return multiple values from a function. This functionality is not however built-in into C#, shame. I think this is a nice feature of the language. It frequently reduces asymptotic complexity (i.e. "performance") without resorting to implementing another class

Continue Reading

Using #region to improve readability of your Code in VS

#region is an interesting instruction that tells Visual Studio how to wrap the code into 'meaningful' chunks. In larger classes, especially, those with several interfaces it is particularly helpful.

Pretty handy if you ask me. The downside is, and I have seen this already a couple of times, is that some engineers use them

Continue Reading

Returning Http Error as Response in WCF

This is arguably one of the more irritating things in WCF, but as it turns out for good reason. WCF is meant to expose services 'universally' of their endpoint i.e. it shouldn't matter how you connect to the server, the service is independent of the underlying protocol. Therefore, returning HTTP errors from WCF service, well,

Continue Reading

Automated WCF RESTful System Testing with VS

Lately, we've been playing around a lot with WCF. Unit testing WCF services is not exactly challenging (well done Microsoft), but it seems that with unit tests it is quite difficult to test certain behaviour, for example, authentication or authorization. There are other means of developing automated tested system tests, but they are not that

Continue Reading

Remember to close files: the process cannot access the file '' because it is being used by another process

I was building a simple web system which relied on XML files. On initiation, the system would open the XML config file, read it and include other XML files defined in it:

The operation was done within a WebForm and it worked just fine. I also had a WCF service whose job was to

Continue Reading

Why is using HTTPS so important?

Internet was undoubtedly one of the biggest inventions in the XX century. It is used for finding relevant information, staying in touch with friends and even shopping. However, due to its very large expansion, on average fewer people are aware of the dangers it poses. Can we protect ourselves? HTTPS is part of the answer.

Continue Reading

Should software engineers be empowered to say “no” to building a given system?

Should software engineers be empowered to say “no” to building a given system? For an employed software engineer the refusal to build a given system may be seen as not performing required tasks. For an unemployed software engineer, it may be another couple of months without a job. The word “no” may be caused by

Continue Reading

Ensuring internal quality of software

Internal quality (aka structural quality or architectural quality[3][9][10]) is an assessment on the quality of the code and its underlying architecture. It differs from external quality which assesses how good the software is in relation to the requirements. Nowadays, as building large scale applications is becoming increasingly common, assessing it, is becoming increasingly important. The

Continue Reading