how to pass parameter to an Expression Method?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello msdn,
<p style="border-width:0px; font:13px/16px "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif; margin:1em 0px; padding:0px; text-align:left; color:#333333; text-transform:none; text-indent:0px; letter-spacing:normal; text-decoration:none; word-spacing:0px; list-style-type:none; white-space:normal; outline-width:0px; orphans:2; widows:2; background-color:#ffffff
how can I send parameter to an Expression method in Linq??
<p style="border-width:0px; font:13px/16px "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif; margin:1em 0px; padding:0px; text-align:left; color:#333333; text-transform:none; text-indent:0px; letter-spacing:normal; text-decoration:none; word-spacing:0px; list-style-type:none; white-space:normal; outline-width:0px; orphans:2; widows:2; background-color:#ffffff
when I am Trying this
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff <span style="border-width:0px; margin:0px; padding:0px; color:blue; font-family:inherit; font-style:inherit; font-weight:inherit; outline-width:0px var y4 = <span style="border-width:0px; margin:0px; padding:0px; color:blue; font-family:inherit; font-style:inherit; font-weight:inherit; outline-width:0px from p <span style="border-width:0px; margin:0px; padding:0px; color:blue; font-family:inherit; font-style:inherit; font-weight:inherit; outline-width:0px in Dc.Table4s <span style="border-width:0px; margin:0px; padding:0px; color:blue; font-family:inherit; font-style:inherit; font-weight:inherit; outline-width:0px where funtion(p) == YesNo.Yes <span style="border-width:0px; margin:0px; padding:0px; color:blue; font-family:inherit; font-style:inherit; font-weight:inherit; outline-width:0px select p;[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff [/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff how to pass p as a parameter and get the same result????[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff my code is given below..[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff [/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff <div style="color:black; background-color:white <pre><span style="color:blue using System;
<span style="color:blue using System.Collections.Generic;
<span style="color:blue using System.Linq;
<span style="color:blue using System.Text;
<span style="color:blue using System.Windows;
<span style="color:blue using System.Windows.Controls;
<span style="color:blue using System.Windows.Data;
<span style="color:blue using System.Windows.Documents;
<span style="color:blue using System.Windows.Input;
<span style="color:blue using System.Windows.Media;
<span style="color:blue using System.Windows.Media.Imaging;
<span style="color:blue using System.Windows.Navigation;
<span style="color:blue using System.Windows.Shapes;
<span style="color:blue using System.Linq.Expressions;
<span style="color:blue using System.Collections;

<span style="color:blue namespace AliasRnD
{
<span style="color:gray /// <span style="color:gray <summary>
<span style="color:gray ///<span style="color:green Interaction logic for MainWindow.xaml
<span style="color:gray /// <span style="color:gray </summary>
<span style="color:blue public <span style="color:blue partial <span style="color:blue class MainWindow : Window
{
<span style="color:blue public MainWindow()
{
InitializeComponent();
DataClasses1DataContext Dc = <span style="color:blue new DataClasses1DataContext();


System.Linq.Expressions.Expression<Func<Table4, Boolean>> expression1 = IsEqual(YesNo.Yes);
<span style="color:blue var funtion = expression1.Compile();

<span style="color:blue var y3 = <span style="color:blue from p <span style="color:blue in Dc.Table4s <span style="color:blue where funtion(<span style="color:blue new Table4(){Num = 1}) <span style="color:blue select p;


<span style="color:blue var y4 = <span style="color:blue from p <span style="color:blue in Dc.Table4s <span style="color:blue where funtion(p) == YesNo.Yes <span style="color:blue select p;

}

Expression<Func<Table4, <span style="color:blue bool>> IsEqual(YesNo val)
{
<span style="color:blue return ((p) => p.Num == (<span style="color:blue int?)val);
}
[/code]
<pre> public enum YesNo : int<br/> {<br/> Yes = 1, No = 2<br/> } }

[/code]

<br/> [/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff [/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff I want to get values of field Num using YesNo Enum if the Num is 1...[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff please help me to solve it out...[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff I am in between a project...any suggestions will be appreciated....[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff [/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff Thank you in Advance [/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff Ranjith[/code]
<pre style="border-width:0px; margin:0px; padding:0px; text-align:left; color:#000000; text-transform:none; line-height:16px; text-indent:0px; letter-spacing:normal; font-family:inherit; font-size:13px; font-style:normal; font-variant:normal; font-weight:normal; text-decoration:none; word-spacing:0px; list-style-type:none; word-wrap:break-word; outline-width:0px; orphans:2; widows:2; background-color:#ffffff [/code]
<br/>
<br/>

View the full article
 

Similar threads

Back
Top