Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

raq query ef core

public static class Helper
{
    public static List<T> RawSqlQuery<T>(string query, Func<DbDataReader, T> map)
    {
        using (var context = new DbContext())
        {
            using (var command = context.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = query;
                command.CommandType = CommandType.Text;

                context.Database.OpenConnection();

                using (var result = command.ExecuteReader())
                {
                    var entities = new List<T>();

                    while (result.Read())
                    {
                        entities.Add(map(result));
                    }

                    return entities;
                }
            }
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: browser folder in wpf 
Csharp :: c# max sequence contains no elements 
Csharp :: update a file where there is a keyword c# 
Csharp :: how to use open hardware monitor in c# 
Csharp :: array in c# 
Csharp :: write last line txt file c# 
Csharp :: generate a dropdown list from array data using razor .net mvc 
Csharp :: factorial of number 
Csharp :: android jaca how to pass a imageurl in a recyclerview adapter 
Csharp :: c# float min value 
Csharp :: play sound in sequence unity 
Csharp :: array sum c# 
Csharp :: c# sort array 
Csharp :: Generic Stack 
Csharp :: c# textbox kodu 
Csharp :: create enum from int c# 
Csharp :: get list of constants in class c# 
Csharp :: save binary data to file c# 
Csharp :: c# how to initialize an array 
Csharp :: asp.net web forms 
Csharp :: unity unit testing 
Csharp :: overridable method C# 
Csharp :: exit form esc winforms 
Csharp :: wpf rounded button 
Csharp :: c# create default instance of type 
Csharp :: how to make font factory text to bold in c# 
Csharp :: clear highlight winforms treeview 
Csharp :: enzymes chemical factory 
Csharp :: delegate 
Csharp :: devexpress aspxdatagridview set VerticalScrollableHeight in codebehind 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =