Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Bastien Vandamme

@Bastien Vandamme
About
Posts
56
Topics
30
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What is the correct way to do Business Validation on entities?
    B Bastien Vandamme

    Hi, What is the correct way to do Business Validation on entities with Entity Framework 6. By business Validation I mean validation that require more than one entity in process with, sometime, a little more complex rules that involve all these entities. A validation that require the system to call he database. I already checked this post: [ScottGu's Blog - Class-Level Model Validation with EF Code First and ASP.NET MVC 3](https://weblogs.asp.net/scottgu/class-level-model-validation-with-ef-code-first-and-asp-net-mvc-3) But, like most example about EF and validation all validations are limited to simple check that consider only the current entity. I need to do some check based on other entities. Example: I have a order entity that contain a quantity of product but this quantity must be a multiple of a variable stored in my item entity. This is what I call the business validation. To perform this validation on order I need to go in database and check the item selected for this order.

    public class Order : IValidateObject
    {
        public int Id { get; set; }
        public int ItemId { get; set; }
        public int Quantity { get; set; }
        
        public IEnumerable Validate(ValidationContext validationContext)
        {
            var item = DbContext.Items.Find(ItemId); // <-- What about this?
            if (Quantity % item.Multiple != 0)
                yield return new ValidationResult("Quantity not multiple of item", new\[\] {Quantity});
        }
    }
    
    public class Item
    {
        public int Id { get; set; }
        public int Multiple { get; set; }
    }
    

    How should I implement this kind of business validation that require other entities? I'm more looking for a good tutorial about this subject. I search but each time I think I find the subject the tutorial is limited to classic validation with Data Annotation or other type of classic validation. Maybe you will juste tell me there is no problem to class my context in the Validate method. It is just that most of tutorial separate the entity layer from the context layer suggesting entities must only be simple POCO with no behavior. I most and most disagree with this but I feel alone.

    C# asp-net tutorial question csharp database

  • Tool to add code in my existing class
    B Bastien Vandamme

    I would like to know if a toll exist to "inject" code in existing class. I'm thinking about a system working with attribute. These attributes are not used at compile or runtime but just to specify part of code I want to inject during coding. For example attribute [LogThis]

        \[LogThis\]
        private void ConsoleTextBox\_TextChanged(object sender, TextChangedEventArgs e)
        {
            consoleTextBox.ScrollToEnd();
        }
    

    Then I run a tool that will add log to all [LogThis] methods

        \[LogThis\]
        private void ConsoleTextBox\_TextChanged(object sender, TextChangedEventArgs e)
        {
            log.Trace("starting ConsoleTextBox\_TextChanged");
            consoleTextBox.ScrollToEnd();
        }
    

    Does somthin similar exists?

    C# debugging tutorial question

  • How to configure azure-pipeline.yml for asp.net core 2.2 ?
    B Bastien Vandamme

    So why the publish tell me the config file is missing when I want to publish on my azure web app? Publish I can do manually with no error. Arrrgggg Microsoft please help. You example are wrong.

    C# tutorial announcement csharp asp-net question

  • How to configure azure-pipeline.yml for asp.net core 2.2 ?
    B Bastien Vandamme

    Hello, I have the feeling this question can become a discussions because there is a lot of parameters that can be change and I don't know what to do. I'm trying to setup a azure pipeline. I already did this in the past but with template and not for a .NET Core web application. It was easy because I could use a template. For some reason, here, I could not chose any template. The Azure Pipeline tool directly ask me to edit a yml file. Maybe because my repository is a local DevOps repository? I have no idea. I followed this tutorial: https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=azure-devops and created this yml file: ``` # ASP.NET Core # Build and test ASP.NET Core projects targeting .NET Core. # Add steps that run tests, create a NuGet package, deploy, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core trigger: - master pool: vmImage: 'Ubuntu-16.04' variables: buildConfiguration: 'Release' steps: # - script: dotnet build --configuration $(buildConfiguration) # displayName: 'dotnet build $(buildConfiguration)' \- task: DotNetCoreInstaller@0 inputs: version: '2.2.202' # replace this value with the version that you need for your project \- script: dotnet restore \- task: DotNetCoreCLI@2 displayName: Build inputs: command: build projects: '**/*.csproj' arguments: '--configuration Release' # Update this to match your need # do this after you've built your app, near the end of your pipeline in most cases # for example, you do this before you deploy to an Azure web app on Windows \- task: DotNetCoreCLI@2 inputs: command: publish publishWebProjects: True arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: True # - task: PublishBuildArtifacts@1 # inputs: # ArtifactName: 'drop' ``` Here is my result: All is success except ``` ##[section]Starting: DotNetCoreCLI ============================================================================== Task : .NET Core Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet. Version : 2.150.1 Author : Microsoft Corporation Help : [More Information](https://go.microsoft.com/fwlink/?linkid=832194) =========================================

    C# tutorial announcement csharp asp-net question

  • OData InvalidOperationException. Bad Request - Error in query syntax
    B Bastien Vandamme

    All my other routes are working fine. GelAll is working, Post is working. I don't get it. Controller name is Classes. Only route that include the key of Booking are not working. What is the logic behind this?

    using Microsoft.AspNet.OData;
    using Microsoft.AspNet.OData.Routing;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.EntityFrameworkCore;
    using Oyg.Domain.DataTypes;
    using System;
    using System.Linq;
    using System.Threading.Tasks;

    namespace Oyg.Api.Controllers
    {
    public partial class ClassesController : ODataController
    {
    /// /// Get all bookings. Get the class reservation queue.
    ///
    ///
    [HttpGet]
    [ODataRoute("Classes({classId})/Bookings")]
    public async Task GetBookings([FromODataUri] Guid classId)
    {
    return Ok(await _context.Bookings
    .Where(y => y.Class.Id == classId)
    .ToListAsync());
    }

        /// /// Get a specific booking
        /// 
        /// 
        \[HttpGet\]
        \[ODataRoute("Classes({classId})/Bookings({bookingId})")\]
        public async Task GetBooking(\[FromODataUri\] Guid classId, \[FromODataUri\] Guid bookingId)
        {
            var @class = await \_context.Classes.FirstOrDefaultAsync(y => y.Id == classId);
    
            if (@class == null)
            {
                return NotFound();
            }
    
            var booking = \_context.Bookings.Where(y => y.Class.Id == classId && y.Id == bookingId);
    
            if (!booking.Any())
            {
                return NotFound();
            }
    
            return Ok(SingleResult.Create(booking));
        }
    
        /// /// Add a booking reservation in a class
        /// 
        /// 
        /// 
        \[HttpPost\]
        \[ODataRoute("Classes({classKey})/Bookings")\]
        public async Task PostBooking(\[FromODataUri\] Guid classKey, \[FromBody\] Booking booking)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
    
            var @class = \_context.Classes
                .FindAsync(classKey);
    
            if (@class == null)
            {
                return NotFound();
            }
    
            booking.Id = Guid.NewGuid();
            booking.Position = \_context.
    
    C# asp-net help csharp database dotnet

  • OData InvalidOperationException. Bad Request - Error in query syntax
    B Bastien Vandamme

    Working with ASP.NET Core and OData v4 I get a

    Quote:

    InvalidOperationException: The path template 'Classes({key})/Bookings({bookingKey})' on the action 'GetBooking' in controller 'Classes' is not a valid OData path template. Bad Request - Error in query syntax.

    I don't see the error in query syntax. Here is the full code of this method in my controller 'Classes'

        /// /// Get a specific booking
        /// 
        /// 
        \[HttpGet\]
        \[ODataRoute("Classes({key})/Bookings({bookingKey})")\]
        public async Task GetBooking(\[FromODataUri\] Guid key, \[FromODataUri\] Guid bookingKey)
        {
            var @class = await \_context.Classes.FirstOrDefaultAsync(y => y.Id == key);
    
            if (@class == null)
            {
                return NotFound();
            }
    
            var booking = \_context.Bookings.Where(y => y.Class.Id == key && y.Id == bookingKey);
    
            if (!booking.Any())
            {
                return NotFound();
            }
    
            return Ok(SingleResult.Create(booking));
        }
    

    This method is defined in 'Classes' Controller. I also have a GeBookings method and 2 actions methods defined that cause no issue. When I comment my GetBooking() method I don't have any error. Booking is a [Contained] ICollection of Booking

    public class Class
    {
        \[Key\]
        public Guid Id { get; set; }
    
        // Others properties
    
        \[Contained\]
        public ICollection Bookings {get; set;}
    }
    

    Maybe I need to do a pause but I really cannot see my error. Were should I look?

    Bastien

    C# asp-net help csharp database dotnet

  • Should a REST API return exception in response body?
    B Bastien Vandamme

    What is the best practice in .NET with Web API? Especially Web REST API. Should a REST API return exception in response body when an exception happens? For sure I will return a 500 or similar HTTP status. But when I response with this error code what are the best practice? Or even better what is the specification or REST API about this? - return the exception (what I do) - return en empty response body? - return an empty of default JSON object? - something else? FYI I'm working on a Web pragmatic REST API in C# .NET that is consumed by a Ruby on Rails team and I'm not sure Ruby code can handle these exception message easily.

    ASP.NET ruby json csharp question collaboration

  • Invoice / Payments history table or statement of account
    B Bastien Vandamme

    Thank you for your reply. Do you have a link to a tutorial or more documentation?

    Algorithms question discussion

  • Invoice / Payments history table or statement of account
    B Bastien Vandamme

    Hello, I need to print statement of account of my clients. I have a table that contains my invoices and another table that contains my payments. Each month I will have to print the history of invoices and payments with last month balance the calculate the new balance.

    Date of transaction Reference Invoice Payment Balance
    2016-02-25 09:23 FLO1602001 2281.2700 0 2281.2700
    2016-02-25 09:51 FLO1602002 18860.1000 0 21141.3700
    2016-04-14 09:39 RV16040100 0 -20205.3700 936

    Could you advise me? What is the best practice? 1. I create a new transaction table and each month I fill this new table with my invoice and payment tables. Or 2. I re-calculate each month my last month balance ?

    Algorithms question discussion

  • Log all request of Web API 2 (DelegatingHandler vs ActionFilterAttribute)
    B Bastien Vandamme

    Searching on the web I found differents solutions to log all requests received by a IIS server. - Solution 1: [DelegatingHandler][1] - Solution 2: [ActionFilterAttribute][2] - Solution 3: [The IIS log][3] I read all articles about these differents solutions and I already implemented and tested them. I don't know wich one to choose between solution 1 and solution 2. Is there an history or performance or architecture maintenance reason that explain a solution is better than another. Are DelegatingHandler and/or ActionFilterAttribute a old feature? [1]: http://stackoverflow.com/a/23660832/196526 [2]: http://www.codeproject.com/Articles/1028416/RESTful-Day-sharp-Request-logging-and-Exception-ha [3]: https://msdn.microsoft.com/en-us/library/ms525410(v=vs.90).aspx

    B413

    ASP.NET visual-studio com sysadmin windows-admin algorithms

  • Consulting company at Hong Kong
    B Bastien Vandamme

    Hello, Could you help me to get contacts to find a developers or IT consulting company at Hong Kong? I don't know where to start.

    Work Issues help question

  • Test AlwaysOn Availability Groups (mirroring)
    B Bastien Vandamme

    Hello, First of all I'm not a SQL DBA. I would like to test the AlwaysOn Availability Groups functionality of SQL server to validate or not if this solution is good for my company. Is it possible to test this for free? What do you suggest?

    Database database sql-server sysadmin question

  • Video capture my debugging actions
    B Bastien Vandamme

    I think there is a tool in Visual Studio to help tester to do image and video capture of they step during manual testing. Could you help me to find more information about it? I think I use bad keyword in Bing/Google because I find many information about debugging but nothing specific to VS. Thank you,

    Design and Architecture visual-studio csharp testing beta-testing help

  • Mobile app universal
    B Bastien Vandamme

    What are the possibilities IDE, language and tools to build an mobile app for iphone, android and windows phone. Is this possible with visual studio without plugins ?

    Mobile visual-studio csharp android ios mobile

  • One Language to rule them all (About business rules)
    B Bastien Vandamme

    I can now confirm it's possible to choose C# to build a Winform application and reuse entities and business rules code from business layer to data and UI layers. I can also confirm this is possible with the solution (mongoDB, Node, JavaScript)

    Design and Architecture database javascript question csharp css

  • REST API generator
    B Bastien Vandamme

    Hello, I'm looking for a REST API generator. I found product like REST United, Swagger, Alpaca, IO-docs, Google API client generator and Postman but they seems to be more documentation or REST client SDK generators. I'looking for the server side REST API generator. I'm looking for something that should be able to connect to my database and let me choose for which table or view I want a readone/readpage/readall/create/update/delete request.

    ASP.NET json database sysadmin announcement

  • WCF Service Application VS ASP.NET Web Application?
    B Bastien Vandamme

    Hello, I'm building a Web API to access my database. I would like to create a Single Page Application Website first then a iPhone, Android and Windows application. Classic. My data and business layer are already finished. 1. First I decided to build a Json WCF Webservice. In Visual Studio I created a WCF Service Application. I modified the Web.config file to accept Json requests and implemented my interface and svc file. 2. After that I discovered ASP.NET Web Application with the Web API template. So I decided to change and to create a real web API with this full website structure. Now I'm lost. What are the differences between these two possibilities to create a Json Web API? What is the best one and for what reason?

    WCF and WF csharp visual-studio json question asp-net

  • I loose my time in config files
    B Bastien Vandamme

    I would like to know. Is it only me or your are also spending more time in config files than really writing code with .NET. I really hate this framework because of that. It's not a framework that is made for developer with a good logical mind that like coding. To master this framework you need memory first and be able to manage the config files first. For one day of development on my machine I need 3 days to configure everything on the production server. The code always works fine on my machine. I never get such problem with other languages.

    C# csharp sysadmin performance help

  • Blog and RSS feeds
    B Bastien Vandamme

    I found the technical blogs on this website but I don't know how to subscribe to a RSS feed of these blogs

    .NET (Core and Framework) csharp tutorial announcement

  • Blog and RSS feeds
    B Bastien Vandamme

    I just notices most of the blogs I used to follow are no more updated by they creator. What are the good .NET / C# / Application Lifecycle blogs with RSS feed of this moment. I prefer to follow people than organizations. I like blogger that write one article, news or tutorial by weak or month. Thank you,

    .NET (Core and Framework) csharp tutorial announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups