Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

 

Problem:

When an Asp.Net Core application attaches data from a SQL server, data return often stops.

The cause is often the data model at sql null values.

In tables, integer numbers are often defined as zero on SQL Server.

 

Solution:

But then you also have to int int in the ASP.Net Core application the placeholders in the data class? Question marks.

Int? Question mark indicates that the value in C# can also be null.

 

 

Daten abfrage in ASP.Net Core Controller

Hier ist auf die Zeilen nFiles null zu achten.

 

Daten aus SQL Server mit null

Name

Value

Type

DtCreated

{01.04.2014 18:15:14}

System.DateTime?

DtEdit

{01.02.2016 08:14:50}

System.DateTime?

Folder

"@/Kontakt"

string

HtmlContent

"Ich bin als Freiberufler, freiberuflicher Programmierer und Selbstständiger

string

IDArticle

33

int

IDUser

null

string

Keywords

"Projekt;Freiberuflich;Freelancer"

string

TextContent

"Ich bin als Freiberufler, freiberuflicher Programmierer und Selbstständiger mit Kollegen

string

Title

"Kontakt Adresse Email Telefon"

string

nFiles

null

int?

nImages

null

int?

nVideos

null

int?

 

 

Data Class in Asp.Net Core

using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

 

#nullable disable

 

namespace CodeDocu.Models

{

    public partial class ArticleModel

    {

        //-------------< Class: Model_Project >-------------

        #region Variables

        //------------< Region: Variables >------------

        //[Required]

        [Key]

        public int IDArticle { get; set; }

        [MaxLength(450)]

        public string IDUser { get; set; }

 

        [MaxLength(255)]

        [Required]

        public string Title { get; set; }

        public string TextContent { get; set; }

        public string HtmlContent { get; set; }

 

        [MaxLength(450)]

        public string Folder { get; set; }

        [MaxLength(450)]

        public string Keywords { get; set; }

 

        public int? nImages { get; set; }

        public int? nVideos { get; set; }

        public int? nFiles { get; set; }

 

        [DisplayFormat(DataFormatString = "{0:d}")] //Format as ShortDateTime

        public DateTime? DtCreated { get; set; }

        [DisplayFormat(DataFormatString = "{0:d}")] //Format as ShortDateTime

        public DateTime? DtEdit { get; set; }

 

        //------------</ Region: Variables >------------

        #endregion /Variables

 

 

 

        #region Class

        //------------< Region: Class >------------

        public ArticleModel()

        {

            //-< init >-           

            DtCreated = DateTime.Now;

            DtEdit = DateTime.Now;

            Title = "";

            TextContent = "";

            HtmlContent = "";

            //-</ init >-

        }

        //------------</ Region: Class >------------

        #endregion /Class

 

        //-------------</ Class: Model_Project >-------------

    }

}

 

 

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de