Posts

Showing posts from November, 2017

Implementing Missing Features in Entity Framework Core

This is the seventh post in a series of posts about bringing the features that were present in Entity Framework pre-Core into EF Core. The others are: Part 1: Introduction, Find, Getting an Entity’s Id Programmatically, Reload, Local, Evict Part 2: Explicit Loading Part 3: Validations Part 4: Conventions Part 5: Getting the SQL for a Query Part 6: Lazy Loading This time I’m going to cover automatic entity configuration in mapping classes, that is, outside of the DbContext.OnModelCreating method. If you remember, Entity Framework Code First supported having classes inheriting from EntityTypeConfiguration in the same assembly as the context . public interface IEntityTypeConfiguration<T> where T : class { void Configure(EntityTypeBuilder<T> entityTypeBuilder); } The actual implementation goes like this: public static class EntityTypeConfigurationExtensions { private static readonly MethodInfo entityMethod = typeof(ModelBuilder).GetTypeInfo().GetMet...

Return multiple values from methods

In this blog, I am going to explain how tuples can be used in C# 7 on wards to return multiple values. Consider the following code from the console application. The method GetDivisionResults accepts two parameters namely number and divisor and returns two integers that are quotient and remainder. static void Main(string[] args) { int number = 17; int devisor = 5; var result = GetDivisionResults(17, 5); Console.WriteLine(“Quotient is ” + result.Item1); Console.WriteLine(“Remainder is ” + result.Item2); } static (int, int) GetDivisionResults(int number, int divisor) { int quotient = number / divisor; int remainder = number % divisor; return (quotient, remainder); } The following function definition defines a function that returns two integer values as tuples. (int, int) GetDevisionREsults(int number, int devisor) (int, int) – defines the return type of the method, which is a tuple contains two integers. I am not concerned about the logic of the application, but...

LA-RAVEL ROUTE PROTECTION WITH INVOKE-1

So we have our basic yaml configuration file with protection turned on. Say we wanted to add in group and permission checks too. I’ve already talked some about this kind of handling in a different post but I’ve more recently simplified it even more, no longer requiring extra classes in the mix. Let’s start by changing our configuration file to tell Invoke that we want to be sure the user is in the “admin” group and has a permission of “delete_user” to access the /admin/user/delete resource: /admin/user/delete: protected: on groups: [admin] permissions: [delete_user] When you fire off the page request for that URL, Invoke will try to call the InvokeUser::getGroups and InvokeUser::getPermissions methods to return the user’s current permission set. Before it required you to use classes that implemented the InvokeGroup and InvokePermission interfaces for each group/permission. I streamlined this since it’s really only evaluating string matches and allowed those methods to eithe...

.NET CORE LOGGING TO MYSQL USING NLOG

Set up the MySQL database MySQL Workbench can be used to add the schema ‘nlog’ which will be used for logging to the MySQL database. The user ‘damienbod’ is also required, which must match the defined user in the connection string. If you configure the MySQL database differently, then you need to change the connection string in the nlog.config file. You also need to create a log table. The following script can be used. If you decide to use NLog.Web in a ASP.NET Core application and add some extra properties, fields to the logs, then this script needs to be extended and also the database target in the nlog.config. CREATE TABLE `log` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Application` varchar(50) DEFAULT NULL, `Logged` datetime DEFAULT NULL, `Level` varchar(50) DEFAULT NULL, `Message` varchar(512) DEFAULT NULL, `Logger` varchar(250) DEFAULT NULL, `Callsite` varchar(512) DEFAULT NULL, `Exception` varchar(512) DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB ...

ANGULAR LAZY LOADING WITH WEB PACK 2-1

AOT production build The webpack.prod.js file requires that the chunkFilename property is set in the output, so that webpack chunks the lazy load modules. output: { path: ‘./wwwroot/’, filename: ‘dist/[name].[hash].bundle.js’, chunkFilename: ‘dist/[id].[hash].chunk.js’, publicPath: ‘/’ }, The angular-router-loader is added to the loaders. The genDir folder defined here must match the definition in tsconfig-aot.json. module: { rules: [ { test: /\.ts$/, loaders: [ ‘awesome-typescript-loader’, ‘angular-router-loader?aot=true&genDir=aot/’ ] }, JIT development build The webpack.dev.js file requires that the chunkFilename property is set in the output, so that webpack chunks the lazy load modules. output: { path: ‘./wwwroot/’, filename: ‘dist/[name].bundle.js’, chunkFilename: ‘dist/[id].chunk.js’, publicPath: ‘/’ }, The angular-router-loader is added to the loaders. module: { rules: [ { test: /\.ts$/, loaders: [ ‘awesome-typescript-loader’, ...

API Integration

RNaura Services  seamlessly helped in Upgrading and improving several small, medium and big shot sized businesses to develop CRM solutions to help them keep things moving. RNaura Services  CRM professionals are well known name in the industry for their CRM expertise to sync domain business processes with familiar to work and recognition for on time and best quality software delivery. Technologies RNaura Services  has vast experience and knowledge in application development that provides insight into the almost relevant, business annalist information for everyone in your organization. Our potential expertise lie in the customization services that has been achieved by way of delivering various CRM projects for clients spread across the globe. We are using Microsoft Certified ASP.Net, C#, VB.Net, HTML, JScript, JQuery & Silverlight etc. comprehensively along with CRM. Methodology Change management from traditional working model towards CRM Analysis of the c...