Example #1
0
		private void dynamicFunctionsButton_Click(object sender, EventArgs e)
		{
			#region Dynamic Function Usage

			Query query = new Query();

			Expression<object> functionBody = new Expression<object>();
			functionBody.Parameters.Add("firstName", typeof (string));
			functionBody.Parameters.Add("lastName", typeof(string));
			functionBody.Text = "lastName + ', ' + firstName";

			MyFunctionBinding myFunctionBinding = new MyFunctionBinding("CreateFullname", functionBody);

			// This adds the dynamic function to the data context
			query.DataContext.Functions.Add(myFunctionBinding);

			query.Text = "SELECT CreateFullname('Abraham', 'Lincoln') AS Result";
			dataGridView1.DataSource = query.ExecuteDataTable();

			#endregion
		}
Example #2
0
        private void dynamicFunctionsButton_Click(object sender, EventArgs e)
        {
            #region Dynamic Function Usage

            Query query = new Query();

            Expression <object> functionBody = new Expression <object>();
            functionBody.Parameters.Add("firstName", typeof(string));
            functionBody.Parameters.Add("lastName", typeof(string));
            functionBody.Text = "lastName + ', ' + firstName";

            MyFunctionBinding myFunctionBinding = new MyFunctionBinding("CreateFullname", functionBody);

            // This adds the dynamic function to the data context
            query.DataContext.Functions.Add(myFunctionBinding);

            query.Text = "SELECT CreateFullname('Abraham', 'Lincoln') AS Result";
            dataGridView1.DataSource = query.ExecuteDataTable();

            #endregion
        }