Skip to content

Commit

Permalink
forcing LF
Browse files Browse the repository at this point in the history
  • Loading branch information
bennettforkner committed Sep 26, 2022
1 parent 0a16903 commit f827bbe
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 68 deletions.
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=lf

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cs text
*.json text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
136 changes: 68 additions & 68 deletions Gordon360/Models/CCT/Context/DbContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Common;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Gordon360.Models.CCT.Context
{
public static class DbContextExtensions
{
public static async Task<List<T>> SqlQueryAsync<T>(this DbContext db, string sql, object[] parameters = null, CancellationToken cancellationToken = default) where T : class
{
if (parameters is null)
{
parameters = new object[] { };
}

if (typeof(T).GetProperties().Any())
{
return await db.Set<T>().FromSqlRaw(sql, parameters).ToListAsync(cancellationToken);
}
else
{
await db.Database.ExecuteSqlRawAsync(sql, parameters, cancellationToken);
return default;
}
}

public static async Task<int> GetNextValueForSequence(this DbContext _context, Sequence sequence)
{
SqlParameter result = new SqlParameter("@result", System.Data.SqlDbType.Int) { Direction = System.Data.ParameterDirection.Output };
await _context.Database.ExecuteSqlRawAsync($"SELECT @result = (NEXT VALUE FOR [{CCTSequenceEnum.GetDescription(sequence)}])", result);
return (int)result.Value;
}
}

public class OutputParameter<TValue>
{
private bool _valueSet = false;

public TValue _value;

public TValue Value
{
get
{
if (!_valueSet)
throw new InvalidOperationException("Value not set.");

return _value;
}
}

internal void SetValue(object value)
{
_valueSet = true;

_value = null == value || Convert.IsDBNull(value) ? default(TValue) : (TValue)value;
}
}
}
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Common;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Gordon360.Models.CCT.Context
{
public static class DbContextExtensions
{
public static async Task<List<T>> SqlQueryAsync<T>(this DbContext db, string sql, object[] parameters = null, CancellationToken cancellationToken = default) where T : class
{
if (parameters is null)
{
parameters = new object[] { };
}

if (typeof(T).GetProperties().Any())
{
return await db.Set<T>().FromSqlRaw(sql, parameters).ToListAsync(cancellationToken);
}
else
{
await db.Database.ExecuteSqlRawAsync(sql, parameters, cancellationToken);
return default;
}
}

public static async Task<int> GetNextValueForSequence(this DbContext _context, Sequence sequence)
{
SqlParameter result = new SqlParameter("@result", System.Data.SqlDbType.Int) { Direction = System.Data.ParameterDirection.Output };
await _context.Database.ExecuteSqlRawAsync($"SELECT @result = (NEXT VALUE FOR [{CCTSequenceEnum.GetDescription(sequence)}])", result);
return (int)result.Value;
}
}

public class OutputParameter<TValue>
{
private bool _valueSet = false;

public TValue _value;

public TValue Value
{
get
{
if (!_valueSet)
throw new InvalidOperationException("Value not set.");

return _value;
}
}

internal void SetValue(object value)
{
_valueSet = true;

_value = null == value || Convert.IsDBNull(value) ? default(TValue) : (TValue)value;
}
}
}

0 comments on commit f827bbe

Please sign in to comment.