예제 #1
0
        /// <summary>
        /// This Method is for including Foreign Key's value to the end result of select statement
        /// </summary>
        /// <typeparam name="T">DataTable</typeparam>
        /// <typeparam name="P"></typeparam>
        /// <param name="self">Ctor</param>
        /// <param name="property"></param>
        /// <returns>Self for Fluent Purposes</returns>
        public static Crud <T> Include <T, P>(this Crud <T> self, Expression <Func <T, P> > property) where T : Datatable
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }
            PropertyInfo prop;

            if (property.Body is UnaryExpression unaryExp && unaryExp.Operand is MemberExpression memberExp)
            {
                prop = (PropertyInfo)memberExp.Member;
                self.AddToForeignKeyList(prop.PropertyType);
                self.AddToProperties(prop);
            }