Это код для сгенерированных классов миграции и моделей:
Код идеи 001
```cs
using System;
using System.Collections.Generic;
namespace IDSCyberProject.Models
{
public partial class Ideas
{
public double? R1pa1vh { get; set; }
public double? R1pm1v { get; set; }
public double? R1pa2vh { get; set; }
public double? R1pm2v { get; set; }
public double? R1pa3vh { get; set; }
public double? R1pm3v { get; set; }
public double? R1pa4ih { get; set; }
public double? R1pm4i { get; set; }
public double? R1pa5ih { get; set; }
public double? R1pm5i { get; set; }
public double? R1pa6ih { get; set; }
public double? R1pm6i { get; set; }
public double? R1pa7vh { get; set; }
public double? R1pm7v { get; set; }
public double? R1pa8vh { get; set; }
public double? R1pm8v { get; set; }
public double? R1pa9vh { get; set; }
public double? R1pm9v { get; set; }
public double? R1pa10ih { get; set; }
public double? R1pm10i { get; set; }
public double? R1pa11ih { get; set; }
public double? R1pm11i { get; set; }
public double? R1pa12ih { get; set; }
public double? R1pm12i { get; set; }
public double? R1f { get; set; }
public double? R1df { get; set; }
public double? R1paz { get; set; }
public double? R1pazh { get; set; }
public double? R1s { get; set; }
public double? R2pa1vh { get; set; }
public double? R2pm1v { get; set; }
public double? R2pa2vh { get; set; }
public double? R2pm2v { get; set; }
public double? R2pa3vh { get; set; }
public double? R2pm3v { get; set; }
public double? R2pa4ih { get; set; }
public double? R2pm4i { get; set; }
public double? R2pa5ih { get; set; }
public double? R2pm5i { get; set; }
public double? R2pa6ih { get; set; }
public double? R2pm6i { get; set; }
public double? R2pa7vh { get; set; }
public double? R2pm7v { get; set; }
public double? R2pa8vh { get; set; }
public double? R2pm8v { get; set; }
public double? R2pa9vh { get; set; }
public double? R2pm9v { get; set; }
public double? R2pa10ih { get; set; }
public double? R2pm10i { get; set; }
public double? R2pa11ih { get; set; }
public double? R2pm11i { get; set; }
public double? R2pa12ih { get; set; }
public double? R2pm12i { get; set; }
public double? R2f { get; set; }
public double? R2df { get; set; }
public double? R2paz { get; set; }
public double? R2pazh { get; set; }
public double? R2s { get; set; }
public double? R3pa1vh { get; set; }
public double? R3pm1v { get; set; }
public double? R3pa2vh { get; set; }
public double? R3pm2v { get; set; }
public double? R3pa3vh { get; set; }
public double? R3pm3v { get; set; }
public double? R3pa4ih { get; set; }
public double? R3pm4i { get; set; }
public double? R3pa5ih { get; set; }
public double? R3pm5i { get; set; }
public double? R3pa6ih { get; set; }
public double? R3pm6i { get; set; }
public double? R3pa7vh { get; set; }
public double? R3pm7v { get; set; }
public double? R3pa8vh { get; set; }
public double? R3pm8v { get; set; }
public double? R3pa9vh { get; set; }
public double? R3pm9v { get; set; }
public double? R3pa10ih { get; set; }
public double? R3pm10i { get; set; }
public double? R3pa11ih { get; set; }
public double? R3pm11i { get; set; }
public double? R3pa12ih { get; set; }
public double? R3pm12i { get; set; }
public double? R3f { get; set; }
public double? R3df { get; set; }
public double? R3paz { get; set; }
public double? R3pazh { get; set; }
public double? R3s { get; set; }
public double? R4pa1vh { get; set; }
public double? R4pm1v { get; set; }
public double? R4pa2vh { get; set; }
public double? R4pm2v { get; set; }
public double? R4pa3vh { get; set; }
public double? R4pm3v { get; set; }
public double? R4pa4ih { get; set; }
public double? R4pm4i { get; set; }
public double? R4pa5ih { get; set; }
Startup.cs код 002
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace IDSCyberProject
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
/*
[Obsolete]
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
var environment = Configuration["ApplicationSettings:Environment"];
}*/
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//services.AddControllersWithViews();
//services.Configure<Models.AppSettings>(Configuration.GetSection("ApplicationSettings"));
//For ASP.NET Core 2.1 and 2.2
//In the ConfigureServices method of the Startup class, Set options.CheckConsentNeeded = context => false; as follows
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential
// cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
// requires using Microsoft.AspNetCore.Http;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc()
.AddJsonOptions(options => {
options.JsonSerializerOptions.IgnoreNullValues.ToString();
});
//services.AddRazorPages();
}
// This method gets called by the runtime. Use this method to configure the HTTP request
pipeline.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "MVC1005:Cannot use
UseMvc with Endpoint Routing.", Justification = "<Pending>")]
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
/*else
{
//app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
//app.UseHsts();
}*/
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
//app.UseMvc();
app.UseRouting();
app.UseAuthorization();
/*app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});*/
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
//endpoints.MapRazorPages();
});
}
}
}
Program.cs код 003 #
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace IDSCyberProject
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
DBIdsContext.cs код 003 #
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace IDSCyberProject.Models
{
public partial class dbidsContext : DbContext
{
public dbidsContext()
{
}
public dbidsContext(DbContextOptions<dbidsContext> options)
: base(options)
{
}
public virtual DbSet<Efmigrationshistory> Efmigrationshistory { get; set; }
public virtual DbSet<Ideas> Ideas { get; set; }
public virtual DbSet<Testids1> Testids1 { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder.UseMySql("Server=localhost;Database=dbids;Uid=admin;Pwd=P@ssw0rd;");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Efmigrationshistory>(entity =>
{
entity.HasKey(e => e.MigrationId)
.HasName("PRIMARY");
entity.ToTable("__efmigrationshistory");
entity.Property(e => e.MigrationId).HasColumnType("varchar(95)");
entity.Property(e => e.ProductVersion)
.IsRequired()
.HasColumnType("varchar(32)");
});
modelBuilder.Entity<Ideas>(entity =>
{
entity.HasNoKey();
entity.ToTable("ideas");
entity.Property(e => e.ControlPanelLog1).HasColumnName("control_panel_log1").HasColumnType("double");
entity.Property(e => e.ControlPanelLog2).HasColumnName("control_panel_log2");
entity.Property(e => e.ControlPanelLog3).HasColumnName("control_panel_log3");
entity.Property(e => e.ControlPanelLog4).HasColumnName("control_panel_log4");
entity.Property(e => e.Filename)
.HasColumnName("filename")
.HasColumnType("int(11)");
entity.Property(e => e.Marker)
.HasColumnName("marker")
.HasColumnType("varchar(100)");
entity.Property(e => e.R1df).HasColumnName("R1DF").HasColumnType("double");
entity.Property(e => e.R1f).HasColumnName("R1F");
entity.Property(e => e.R1pa10ih).HasColumnName("R1PA10IH");
entity.Property(e => e.R1pa11ih).HasColumnName("R1PA11IH");
entity.Property(e => e.R1pa12ih).HasColumnName("R1PA12IH");
entity.Property(e => e.R1pa1vh).HasColumnName("R1PA1VH");
entity.Property(e => e.R1pa2vh).HasColumnName("R1PA2VH");
entity.Property(e => e.R1pa3vh).HasColumnName("R1PA3VH");
entity.Property(e => e.R1pa4ih).HasColumnName("R1PA4IH");
entity.Property(e => e.R1pa5ih).HasColumnName("R1PA5IH");
entity.Property(e => e.R1pa6ih).HasColumnName("R1PA6IH");
entity.Property(e => e.R1pa7vh).HasColumnName("R1PA7VH");
entity.Property(e => e.R1pa8vh).HasColumnName("R1PA8VH");
entity.Property(e => e.R1pa9vh).HasColumnName("R1PA9VH");
entity.Property(e => e.R1paz).HasColumnName("R1PAZ");
entity.Property(e => e.R1pazh).HasColumnName("R1PAZH");
entity.Property(e => e.R1pm10i).HasColumnName("R1PM10I");
entity.Property(e => e.R1pm11i).HasColumnName("R1PM11I");
entity.Property(e => e.R1pm12i).HasColumnName("R1PM12I");
entity.Property(e => e.R1pm1v).HasColumnName("R1PM1V");
entity.Property(e => e.R1pm2v).HasColumnName("R1PM2V");
entity.Property(e => e.R1pm3v).HasColumnName("R1PM3V");
entity.Property(e => e.R1pm4i).HasColumnName("R1PM4I");
entity.Property(e => e.R1pm5i).HasColumnName("R1PM5I");
entity.Property(e => e.R1pm6i).HasColumnName("R1PM6I");
entity.Property(e => e.R1pm7v).HasColumnName("R1PM7V");
entity.Property(e => e.R1pm8v).HasColumnName("R1PM8V");
entity.Property(e => e.R1pm9v).HasColumnName("R1PM9V");
entity.Property(e => e.R1s).HasColumnName("R1S");
entity.Property(e => e.R2df).HasColumnName("R2DF");
entity.Property(e => e.R2f).HasColumnName("R2F");
entity.Property(e => e.R2pa10ih).HasColumnName("R2PA10IH");
entity.Property(e => e.R2pa11ih).HasColumnName("R2PA11IH");
entity.Property(e => e.R2pa12ih).HasColumnName("R2PA12IH");
entity.Property(e => e.R2pa1vh).HasColumnName("R2PA1VH");
entity.Property(e => e.R2pa2vh).HasColumnName("R2PA2VH");
entity.Property(e => e.R2pa3vh).HasColumnName("R2PA3VH");
entity.Property(e => e.R2pa4ih).HasColumnName("R2PA4IH");
entity.Property(e => e.R2pa5ih).HasColumnName("R2PA5IH");
entity.Property(e => e.R2pa6ih).HasColumnName("R2PA6IH");
entity.Property(e => e.R2pa7vh).HasColumnName("R2PA7VH");
entity.Property(e => e.R2pa8vh).HasColumnName("R2PA8VH");
entity.Property(e => e.R2pa9vh).HasColumnName("R2PA9VH");
entity.Property(e => e.R2paz).HasColumnName("R2PAZ");
entity.Property(e => e.R2pazh).HasColumnName("R2PAZH");
entity.Property(e => e.R2pm10i).HasColumnName("R2PM10I");
entity.Property(e => e.R2pm11i).HasColumnName("R2PM11I");
entity.Property(e => e.R2pm12i).HasColumnName("R2PM12I");
entity.Property(e => e.R2pm1v).HasColumnName("R2PM1V");
entity.Property(e => e.R2pm2v).HasColumnName("R2PM2V");
entity.Property(e => e.R2pm3v).HasColumnName("R2PM3V");
entity.Property(e => e.R2pm4i).HasColumnName("R2PM4I");
entity.Property(e => e.R2pm5i).HasColumnName("R2PM5I");
entity.Property(e => e.R2pm6i).HasColumnName("R2PM6I");
entity.Property(e => e.R2pm7v).HasColumnName("R2PM7V");
entity.Property(e => e.R2pm8v).HasColumnName("R2PM8V");
entity.Property(e => e.R2pm9v).HasColumnName("R2PM9V");
entity.Property(e => e.R2s).HasColumnName("R2S");
entity.Property(e => e.R3df).HasColumnName("R3DF");
entity.Property(e => e.R3f).HasColumnName("R3F");
entity.Property(e => e.R3pa10ih).HasColumnName("R3PA10IH");
entity.Property(e => e.R3pa11ih).HasColumnName("R3PA11IH");
entity.Property(e => e.R3pa12ih).HasColumnName("R3PA12IH");
entity.Property(e => e.R3pa1vh).HasColumnName("R3PA1VH");
entity.Property(e => e.R3pa2vh).HasColumnName("R3PA2VH");
entity.Property(e => e.R3pa3vh).HasColumnName("R3PA3VH");
entity.Property(e => e.R3pa4ih).HasColumnName("R3PA4IH");
entity.Property(e => e.R3pa5ih).HasColumnName("R3PA5IH");
entity.Property(e => e.R3pa6ih).HasColumnName("R3PA6IH");
entity.Property(e => e.R3pa7vh).HasColumnName("R3PA7VH");
entity.Property(e => e.R3pa8vh).HasColumnName("R3PA8VH");
entity.Property(e => e.R3pa9vh).HasColumnName("R3PA9VH");
entity.Property(e => e.R3paz).HasColumnName("R3PAZ");
entity.Property(e => e.R3pazh).HasColumnName("R3PAZH");
entity.Property(e => e.R3pm10i).HasColumnName("R3PM10I");
entity.Property(e => e.R3pm11i).HasColumnName("R3PM11I");
entity.Property(e => e.R3pm12i).HasColumnName("R3PM12I");
entity.Property(e => e.R3pm1v).HasColumnName("R3PM1V");
entity.Property(e => e.R3pm2v).HasColumnName("R3PM2V");
entity.Property(e => e.R3pm3v).HasColumnName("R3PM3V");
entity.Property(e => e.R3pm4i).HasColumnName("R3PM4I");
entity.Property(e => e.R3pm5i).HasColumnName("R3PM5I");
entity.Property(e => e.R3pm6i).HasColumnName("R3PM6I");
entity.Property(e => e.R3pm7v).HasColumnName("R3PM7V");
entity.Property(e => e.R3pm8v).HasColumnName("R3PM8V");
entity.Property(e => e.R3pm9v).HasColumnName("R3PM9V");
entity.Property(e => e.R3s).HasColumnName("R3S");
entity.Property(e => e.R4df).HasColumnName("R4DF");
entity.Property(e => e.R4f).HasColumnName("R4F");
entity.Property(e => e.R4pa10ih).HasColumnName("R4PA10IH");
entity.Property(e => e.R4pa11ih).HasColumnName("R4PA11IH");
entity.Property(e => e.R4pa12ih).HasColumnName("R4PA12IH");
entity.Property(e => e.R4pa1vh).HasColumnName("R4PA1VH");
entity.Property(e => e.R4pa2vh).HasColumnName("R4PA2VH");
entity.Property(e => e.R4pa3vh).HasColumnName("R4PA3VH");
entity.Property(e => e.R4pa4ih).HasColumnName("R4PA4IH");
entity.Property(e => e.R4pa5ih).HasColumnName("R4PA5IH");
entity.Property(e => e.R4pa6ih).HasColumnName("R4PA6IH");
entity.Property(e => e.R4pa7vh).HasColumnName("R4PA7VH");
entity.Property(e => e.R4pa8vh).HasColumnName("R4PA8VH");
entity.Property(e => e.R4pa9vh).HasColumnName("R4PA9VH");
entity.Property(e => e.R4paz).HasColumnName("R4PAZ");
entity.Property(e => e.R4pazh).HasColumnName("R4PAZH");
entity.Property(e => e.R4pm10i).HasColumnName("R4PM10I");
entity.Property(e => e.R4pm11i).HasColumnName("R4PM11I");
entity.Property(e => e.R4pm12i).HasColumnName("R4PM12I");
entity.Property(e => e.R4pm1v).HasColumnName("R4PM1V");
entity.Property(e => e.R4pm2v).HasColumnName("R4PM2V");
entity.Property(e => e.R4pm3v).HasColumnName("R4PM3V");
entity.Property(e => e.R4pm4i).HasColumnName("R4PM4I");
entity.Property(e => e.R4pm5i).HasColumnName("R4PM5I");
entity.Property(e => e.R4pm6i).HasColumnName("R4PM6I");
entity.Property(e => e.R4pm7v).HasColumnName("R4PM7V");
entity.Property(e => e.R4pm8v).HasColumnName("R4PM8V");
entity.Property(e => e.R4pm9v).HasColumnName("R4PM9V");
entity.Property(e => e.R4s).HasColumnName("R4S");
entity.Property(e => e.Relay1Log).HasColumnName("relay1_log");
entity.Property(e => e.Relay2Log).HasColumnName("relay2_log");
entity.Property(e => e.Relay3Log).HasColumnName("relay3_log");
entity.Property(e => e.Relay4Log).HasColumnName("relay4_log");
entity.Property(e => e.SnortLog1).HasColumnName("snort_log1");
entity.Property(e => e.SnortLog2).HasColumnName("snort_log2");
entity.Property(e => e.SnortLog3).HasColumnName("snort_log3");
entity.Property(e => e.SnortLog4).HasColumnName("snort_log4");
});
modelBuilder.Entity<Testids1>(entity =>
{
entity.HasNoKey();
entity.ToTable("testids1");
entity.Property(e => e.ColumnA).HasColumnType("int(11)");
entity.Property(e => e.ColumnB).HasColumnType("int(11)");
entity.Property(e => e.ColumnC).HasColumnType("int(11)");
entity.Property(e => e.ColumnD).HasColumnType("int(11)");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}
Контроллер
Этот контроллер был
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Linq;
namespace IDSProject_DS_29_10_19.Controllers
{
[Produces("application/json")]
[Route("api/[controller]")]
[ApiController]
[Route("[controller]")]
public class Ideas : ControllerBase
{
public Ideas(ILogger<Ideas> logger)
{
_logger = logger;
}
private readonly ILogger<Ideas> _logger;
[HttpGet]
public IEnumerable<Models.Ideas> Get()
{
//var rng = new Random();
return Enumerable.Range(1, 2).Select(index => new Models.Ideas { Filename = 11 }).ToArray();
}
}
Проблема в том, что в коде отображаются значения NULL в моем коде URL. Как решить эту проблему, если в базе данных есть числовые значения, где большинство значений имеют тип «double».