Base solution for your next web application

Activities of "TimMackey"

@maliming - Is there another way to write to the db without being supplied the service's IRepository object? Can I obtain it locally? If so, how? Or must I pass the service's IRepository object down from the top?

I need to access my db outside the typical .Application service (which uses injected IRepository objects). The table has been created with the migrator via the following:

protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.CreateTable(
        name: "TtmErrorLog",
        columns: table => new
        {
            LogId = table.Column<int>(nullable: false)
                .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
            ErrorDate = table.Column<DateTime>(nullable: false),
            CreateBy = table.Column<long>(nullable: true),
            ErrorText = table.Column<string>(nullable: true)
        },
        constraints: table =>
        {
            table.PrimaryKey("PK_TtmErrorLog", x => x.LogId);
        });
}

The context::

using System.Data.Entity;

namespace ExceptionsLibrary
{
    public class ErrorLogContext : DbContext
    {
        public ErrorLogContext() : base("ngTTMDb")
        {
        }
        public DbSet<ErrorLog> ErrorLogs { get; set; }
    }
}

The table object:

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ExceptionsLibrary
{
    [Table("TtmErrorLog")]
    public class ErrorLog
    {
        [Key]
        public int LogId { get; set; }

        public System.DateTime ErrorDate { get; set; }

        public long? CreateBy { get; set; }

        public string ErrorText { get; set; }
    }
}

The ErrorWriter library has the following:

    public class ErrorWriter
    {
        private static ErrorLogContext errLogContext;
        private ErrorLog errorItem;
        private StringBuilder memoryString;
        
        public void Init()
        {
            errLogContext = new ErrorLogContext();
            errorItem = new ErrorLog;
        }
        public void writelog(int userId, string errmsg)
        {
            using (SqlConnection con = new SqlConnection(errLogContext.Database.Connection.ConnectionString))
                {
                    errorItem.CreateBy = userId;
                    errorItem.ErrorText = errmsg;
                    errLogContext.ErrorLogs.Add(errorItem);
                    errLogContext.SaveChanges();
                    con.Close();
                }
        }
    }

App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

Installed packages:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.2.0" targetFramework="net452" />
  <package id="System.Data.Common" version="4.3.0" targetFramework="net452" />
  <package id="System.Data.SqlClient" version="4.6.0" targetFramework="net452" />
</packages>

My app is Angular/Core. The code above has been migrated from another working app. I'm using the default MS-SQL Server that ANZ provides. The problem is an Exception is thrown when ' errLogContext.ErrorLogs.Add(errorItem);' is executed. The full Exception message is:

Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.

How is the factory provided and registered?

Is there a way for ANZ to consolidate/merge ANZ and Abp migrations periodically into a single migration (or one each for ANZ and Abp) for major releases going forward? i.e. 7.0.0, 8.0.0, etc.

My project currently has 60 merges between ANZ, Abp, and my own. I plan to merge my migrations to a single "Initial" migration as soon as my initial development phase has completed. Would like to keep the number of migration files to a minimum by merging migrations on a release schedule.

Can this be done? How might consolidated migrations be applied to the db once the app has been put into production?

Thank you.

Issue solved. Thank you.

I'm migrating a file from another working app into .Core project. I'm not able to find a package or library to supply the Graphics class, hence, the symbol remains unresolved.

using System.Drawing;

public int X, Y, Width, Height;

public int Draw_Box(Graphics gfx)
{
    gfx.DrawRectangle(Pen,  X, Y, Width, Height);
    return Height;
}

The Graphics class is resolved in .Application project.

What package/library will resolve the reference in .Core project?

Unintentionally closed. Would like to see a solution.

Upon further investigation it seems that the tool can't handle binary.

namespace ngTTM.TtmDataModel
{
    public enum TtmSampleEnum
    {

        Undefined = 0,

        HasGuid = 0b0__0000_0100_0000_0000,
        NooGuid = 0b0__0000_0000_0000_0000,

    }
}

When adding a new property of type 'enum', the drop-down list of enum types presents some of my custom enums and not others. All my enum files are in the same folder and are the same namespace in *.Core.Shared. How does RAD tool determine which enums to include in its drop-down list, and which enums to ignore?

UPDATE: Implemented your change on only 1 of 2 methods of the same method signature. When implemented on both methods, everything works. Thank you for your assistance.

yes, per your instructions.

 [HttpPost]
        public async Task<TtmSeatGridDto> GetSeatGrid(GetSeatGridInput seatGridFilter)
        { ... }
Showing 261 to 270 of 398 entries