Category: HowTo

  • Poor Man Display Errors–part 1 – idea

    Let’s be honest,debugging can be a pain. You build your beautiful new web app (built with a snazzy backend API like .NET Core and a Blazor frontend – you know the drill!),everything seems great…until it isn’t. Suddenly,you are hitting errors,but you’re stuck hunting for clues in endless log files. Sound familiar? Wouldn’t it be amazing…

  • Circular references on .NET,Entity Framework and WebAPI

    Imagine having a class Department( ID,Name) and Employee ( ID,Name,IDDepartment) . You want to return in the WebAPI the Departments with the Employee . It is simple to wrote this code: [code lang=”csharp”] [HttpGet] public IEnumerable<Department> Get([FromServices] MyTestDatabaseContext context) { var departments = context.Department.Include(iterator=>iterator.Employee).ToArray(); return departments; } [/code] But the problem is with circular references…

  • InternalsVisibleTo usage

    I do not know if you know  InternalsVisibleToAttribute https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396  . I have used on a project https://github.com/ignatandrei/WorldBankAPi,that deals with World Bank API to get information Let’s take an example: Countries: http://api.worldbank.org/countries?format=json I have had a class CountriesRepository,that deals with transforming countries Json from WorldBank to Country classes. How can I test it WITHOUT relying on…

  • Maintaining history of data

      What is this about? I tend to quote Fowler: “Usually when we see properties on a class,they represent questions we can ask of an object now. However there are times when we don’t want to just ask questions about a property of an object now,we also want to ask these questions about some point…

  • Five common mistakes for ASP.NET MVC accesing resources : css,js,images,ajax

    This is a Razor /MVC5 variant of older post http://msprogrammer.serviciipeweb.ro/2010/10/09/five-common-mistakes-for-asp-net-mvc-accesing-resources-css-js-images-ajax/ To have once for all the link to show to people,because too much makes the same error again and again. (From here – you can use ResolveUrl or Url.Content – it’s the same for me. I use ResolveUrl because I used first …) Case 1…

  • 7 rules of logging ( and 7 notes)

    Those are my 7 rules for logging (you can read also the side note for every rule) So here they are: Logging is good for developers,not for the user . You should not re-invent logging framework – just use one that exists in your programming language. The logging should not affect the usual behavior of…

  • 5 Minutes .NET–Memory Cache

      At https://youtu.be/BL5yo_p7x-E you can find the new video about caching in .NET with Memory Cache. The code is:   [code lang=”csharp”] using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Caching; using System.Text; using System.Threading.Tasks; namespace MemoryCacheNet { public static class GlobalData { static object lockMe = new object(); public static List<string> CountryList() { string key…

  • EF Record and play – conclusions

      Part 1 : What is EF record and play : http://msprogrammer.serviciipeweb.ro/2014/11/29/entity-framework-6-record-and-play-1-of-5/  Part 2: EF Record and play use: Testing : http://msprogrammer.serviciipeweb.ro/2014/12/08/entity-framework-6-record-and-play-use-unit-testing-part-2-of-5/ Part 3: EF Record and play use: Make demo: http://msprogrammer.serviciipeweb.ro/2014/12/14/entity-framework-6-record-and-play-use-making-demos-part-3-of-5/  Part 4: EF Record and play use: Record user Sql when a bug occurs: http://msprogrammer.serviciipeweb.ro/2014/12/26/ef-record-and-play-use-recording-user-sql-when-a-bug-occurred-part-4-of-5/ Part 5: EF record and play: conclusions: http://msprogrammer.serviciipeweb.ro/2015/01/05/ef-record-and-play-conclusions/…

  • EF Record and play use: Recording user sql when a bug occurred (part 4 of 5)

      Part 1 : What is EF record and play : http://msprogrammer.serviciipeweb.ro/2014/11/29/entity-framework-6-record-and-play-1-of-5/  Part 2: EF Record and play use: Testing : http://msprogrammer.serviciipeweb.ro/2014/12/08/entity-framework-6-record-and-play-use-unit-testing-part-2-of-5/ Part 3: EF Record and play use: Make demo: http://msprogrammer.serviciipeweb.ro/2014/12/14/entity-framework-6-record-and-play-use-making-demos-part-3-of-5/  Part 4: EF Record and play use: Record user Sql when a bug occurs: http://msprogrammer.serviciipeweb.ro/2014/12/26/ef-record-and-play-use-recording-user-sql-when-a-bug-occurred-part-4-of-5/ Part 5: EF record and play: conclusions: http://msprogrammer.serviciipeweb.ro/2015/01/05/ef-record-and-play-conclusions/…

  • Entity Framework 6 Record and play use : Making demos ( part 3 of 5)

      Part 1 : What is EF record and play : http://msprogrammer.serviciipeweb.ro/2014/11/29/entity-framework-6-record-and-play-1-of-5/  Part 2: EF Record and play use: Testing : http://msprogrammer.serviciipeweb.ro/2014/12/08/entity-framework-6-record-and-play-use-unit-testing-part-2-of-5/ Part 3: EF Record and play use: Make demo: http://msprogrammer.serviciipeweb.ro/2014/12/14/entity-framework-6-record-and-play-use-making-demos-part-3-of-5/  Part 4: EF Record and play use: Record user Sql when a bug occurs: http://msprogrammer.serviciipeweb.ro/2014/12/26/ef-record-and-play-use-recording-user-sql-when-a-bug-occurred-part-4-of-5/ Part 5: EF record and play: conclusions: http://msprogrammer.serviciipeweb.ro/2015/01/05/ef-record-and-play-conclusions/…