![](/Images/OutliningIndicators/ContractedBlock.gif)
Code
using System;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq.Expressions;
namespace KingRi.Test
{
[Table(Name="account")]
public class Account
{
[Column(Name="uname", DbType="varchar(50) NOT NULL")]
public string Uname
{
get;
set;
}
[Column(Name="upass", DbType="varchar(50)")]
public string Upass
{
get;
set;
}
}
public delegate void SelectDelegate<T1, T>(Account u);
public class Client
{
static void Main()
{
DataContext ctx = new DataContext("server=.;database=t1;uid=sa;pwd=");
Table<Account> users = ctx.GetTable<Account>();
//IQueryable<Account> result = from u in users select u;
IQueryable<string> result = users.Select<Account,string>(u=>u.Uname);
/*
ParameterExpression expression;
IQueryable<Account> result = users.Select<Account,Account>(
Expression.Lambda<Func<Account,Account>>(
expression=Expression.Parameter(typeof(Account), "u"),
new ParameterExpression[] {expression}
)
);
*/
foreach(string a in result)
{
Console.WriteLine(a);
}
}
}
}