Get the App
SLTechnology News&Howtos  ›  Development  › 

How SqlDataReader generates dynamic Lambda expressions

Shulou Source: shulou.com Published: 2022-06-03 14:06:50 11月14日 Update

This article mainly introduces how SqlDataReader generates dynamic Lambda expressions. It is very detailed and has certain reference value. Friends who are interested must read it!

In the processing of the stream object SqlDataReader returned by SqlServer, the entity is also transformed by dynamically generating Lambda expressions.

First the previous version of the code

Using System;using System.Collections.Generic;using System.Data;using System.Data.Common;using System.Data.SqlClient;using System.Linq;using System.Linq.Expressions;using System.Reflection;using System.Text;using System.Threading.Tasks Namespace Demo1 {public static class EntityConverter {# region / DataTable generate entity / public static List ToList (this DataTable dataTable) where T: class, new () {if (dataTable = = null | | dataTable.Rows.Count 0) {cmd.Parameters.AddRange (pms);} conn.Open (); return cmd.ExecuteReader (CommandBehavior.CloseConnection);} class Usr {public Int32 ID {get; set } public String Name {get; set;}} above is all the content of the article "how SqlDataReader generates dynamic Lambda expressions". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Generation expressions objects dynamic entities Code content articles previous values interests foundations guys Partners ways methods more knowledge Industry Information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Xiaomi OPPO Reno Shulou Information