This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using Microsoft.AspNetCore.Html; | |
using Newtonsoft.Json; | |
namespace HtmlHelpers | |
{ | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null) | |
{ | |
using (db.Connection.EnsureOpen()) | |
{ | |
try | |
{ | |
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList(); | |
} | |
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MetadataWorkspace LoadEdmx(string path) | |
{ | |
var runtime = XElement.Load(path).Elements().First(e => e.Name.LocalName == "Runtime"); | |
EdmItemCollection edmCollection; | |
var csdl = runtime.Elements().First(e => e.Name.LocalName == "ConceptualModels") | |
.Elements().First(e => e.Name.LocalName == "Schema"); | |
using (var reader = csdl.CreateReader()) | |
{ | |
edmCollection = new EdmItemCollection(new[] { reader }); |