System.Linq.Expressions.Expression.ListBind C# (CSharp) Method

ListBind() public static method

Creates a MemberListBinding where the member is a field or property.
/// is null. -or-One or more elements of is null. /// does not represent a field or property.-or-The or of the field or property that represents does not implement .
public static ListBind ( MemberInfo member ) : MemberListBinding
member System.Reflection.MemberInfo A that represents a field or property to set the property equal to.
return MemberListBinding
        public static MemberListBinding ListBind(MemberInfo member, params ElementInit[] initializers)
        {
            return ListBind(member, (IEnumerable<ElementInit>)initializers);
        }

Same methods

Expression::ListBind ( MemberInfo member, IEnumerable initializers ) : MemberListBinding
Expression::ListBind ( MethodInfo propertyAccessor ) : MemberListBinding
Expression::ListBind ( MethodInfo propertyAccessor, IEnumerable initializers ) : MemberListBinding

Usage Example

        public void MemberInit_list_bind()
        {
            var expression =
                LinqExpression.MemberInit(
                    LinqExpression.New(
                        typeof(SampleClass)),
                    LinqExpression.ListBind(
                        typeof(SampleClass).GetProperty(nameof(SampleClass.ListProperty)),
                        LinqExpression.ElementInit(
                            typeof(List <long>).GetMethod("Add"),
                            LinqExpression.Constant(0L))));

            ShouldRoundrip(expression);
        }
All Usage Examples Of System.Linq.Expressions.Expression::ListBind
Expression