linq dynamic query using linq expression

Posted by Ramjill under C# on 9/25/2012 | Points: 10 | Views : 1122 | Status : [Member] | Replies : 0
hi,

i need to convert below static linq expression to dynamic. please check my expression below.

Collapse | Copy Code
Class1 objClassBO = datafromdb();

//This is my linq static expression

Class2 objClassDC = new Class2()
{
Field1 = objClassBO.Field1,
Field2 = objClassBO.Field2,
Field3 = objClassBO.Field3.Cast<class3>().Select(j =&gt;new Class4
{
Field1 = j.Field1,
Field2 = j.Field2
}).ToArray()
};

//Sample classes

public class Class1
{
public int Field1 { get; set; }
public int Field2 { get; set; }
public Class3[] Field3 { get; set; }
}

public class Class2
{
public int Field1 { get; set; }
public int Field2 { get; set; }
public Class4[] Field3 { get; set; }
}

public class Class3
{
public int Field1 { get; set; }
public int Field2 { get; set; }
}

public class Class4
{
public int Field1 { get; set; }
public int Field2 { get; set; }
}

Thanks in advance




Responses

(No response found.)

Login to post response