Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# , how to create object instance by using expression

C# , how to create object instance by using expression

Scheduled Pinned Locked Moved C#
helpcsharpdatabasetutorialquestion
1 Posts 1 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goldli88
    wrote on last edited by
    #1

    I'm trying to using expression to create object instance, but i got an error 'System.Reflection.TargetParameterCountException'. my code is bellow , and i don't know what's the problem, please help. using BenchmarkDotNet.Attributes; using FastExpressionCompiler.LightExpression; using FastMember; using System; using System.Collections.Concurrent; using System.Diagnostics; using System.Reflection; using System.Threading.Tasks; using static FastExpressionCompiler.LightExpression.ExpressionCompiler; namespace ConsoleApp2 { public class Program { static void Main(string[] args) { TestExpressionCreate(); TestActivatorCreate(); //var summary = BenchmarkRunner.Run(); Console.ReadLine(); } #region [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public class FieldAttribute : Attribute { private bool _isSizeExtracted; private string _size; public FieldAttribute(string dataType = null) { if (!string.IsNullOrWhiteSpace(dataType)) { DataType = dataType.ToLower(); } } public int? Index { get; set; } public string FieldName { get; set; } public bool HasDefaultValue { get; set; } public string DataType { get; set; } internal string Size { get { if (string.IsNullOrWhiteSpace(DataType)) return null; if (!_isSizeExtracted) { _isSizeExtracted = true; var i = DataType.IndexOf('('); if (i > 0) { var j = DataType.IndexOf(')', i); if (j > 0) { //_size = DataType[(i + 1)..j]; } } } return _size; } } } internal class TableInfo { } internal class FieldInfoBase { internal int Index { get; set; } internal string FieldName { get; set; } internal bool HasDefaultValue

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups