Giter Club home page Giter Club logo

transformalize.provider.razor's Introduction

Overview

This is a Razor provider and transform for Transformalize using RazorEngine for the .NET Framework and RazorEngineCore for .NET Core.

Write Usage

<add name='TestProcess' mode='init'>
  <connections>
    <add name='input' provider='bogus' seed='1' />
    <add name='output' provider='Razor' template='template.cshtml' file='output.html' />
  </connections>
  <entities>
    <add name='Contact' size='1000'>
      <fields>
        <add name='Identity' type='int' primary-key='true' />
        <add name='FirstName' />
        <add name='LastName' />
        <add name='Stars' type='byte' min='1' max='5' />
        <add name='Reviewers' type='int' min='0' max='500' />
      </fields>
    </add>
  </entities>
</add>

This writes 1000 rows of bogus data to output.html.

The template template.cshtml is passed a RazorModel. The template in this example looks like this:

@model Transformalize.Providers.Razor.RazorModel
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Razor Output</title>
</head>
<body>
    <table>
        <thead>
            <tr>
                @foreach (var field in Model.Entity.Fields.Where(f => !f.System)) {
                    <th>@field.Label</th>
                }
            </tr>
        </thead>
        <tbody>
            @foreach (var row in Model.Rows) {
                <tr>
                    @foreach (var field in Model.Entity.Fields.Where(f => !f.System)) {
                        <td>@(row[field])</td>
                    }
                </tr>
                ++Model.Entity.Inserts;
            }
        </tbody>
    </table>
</body>
</html>

The table in output.html looks like this (clipped for brevity):

Identity FirstName LastName Stars Reviewers
1 Justin Konopelski 3 153
2 Eula Schinner 2 41
3 Tanya Shanahan 4 412
4 Emilio Hand 4 469
5 Rachel Abshire 3 341

Benchmark

Note: Numbers get better with more records.

BenchmarkDotNet=v0.11.3, OS=Windows 10.0.18363
Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
  [Host]       : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.8.4150.0
  LegacyJitX64 : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit LegacyJIT/clrjit-v4.8.4150.0;compatjit-v4.8.4150.0

Job=LegacyJitX64  Jit=LegacyJit  Platform=X64  
Runtime=Clr  
Method Mean Error StdDev Ratio RatioSD
'10000 test rows' 871.0 ms 12.63 ms 11.82 ms 1.00 0.00
'10000 rows with 1 razor' 1,222.3 ms 23.75 ms 30.03 ms 1.41 0.05
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.1.201
  [Host]    : .NET Core 3.1.3 (CoreCLR 4.700.20.11803, CoreFX 4.700.20.12001), X64 RyuJIT
  RyuJitX64 : .NET Core 3.1.3 (CoreCLR 4.700.20.11803, CoreFX 4.700.20.12001), X64 RyuJIT

Job=RyuJitX64  Jit=RyuJit  Platform=X64  
Method Mean Error StdDev Ratio
'10000 test rows' 649.3 ms 5.51 ms 5.15 ms 1.00
'10000 rows with 1 razor' 850.6 ms 7.03 ms 6.58 ms 1.31

transformalize.provider.razor's People

Contributors

dalenewman avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.