8,497
社区成员
发帖
与我相关
我的任务
分享
from t in Table1
where Method1(t.Field1)==1
select t
int Method1(string data)
{
//处理data数据,返回int
}
Func<string, int > fn = (data) => int.Parse(data)+60;
var query=from t1 in Table1 where fn(t1.Field1)==100
select t1;
query.Dump();
//将此方法代码帖上来
int Method1(string data)
{
//处理data数据,返回int
}
//work
Func<string, int > fn = (data) => int.Parse(data)+60;
var strings=new []{"40","50","60"};
var query1=from t1 in strings where fn(t1)==100 select t1;
query1.Dump();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
/// <summary>
/// Struct or Class
/// Data Model
/// </summary>
public struct Products
{
public string number;
//..other field;
//..
//..
}
class Program
{
static void Main(string[] args)
{
List<Products> tmpList = new List<Products>();//like your table1
//insert a data to the table
#region Test Data
Products product = new Products();
product.number = "2";
tmpList.Add(product);
#endregion
// this is what you want
var tmpList1 = tmpList.Where(t => Method(t.number).Equals(10002));//Lamada Form
//your Form:
//var tmpList1 = from t in tmpList where Method(t.number) == 10002 select t;
//check the result
foreach(var item in tmpList1)
{
Console.WriteLine(item.number);
}
Console.Read();
}
static int Method(string data)
{
//Your Process
return int.Parse("1000" + data);//Just a Sample
}
}
}
VS2010测试通过~
var query=from t1 in Table1 where Convert.ToInt32(t1.Field1)+60==100
select t1;
query.Dump();
var query=from t1 in Table1 where t1.Field1==40 //这不画蛇添足嘛,是直接写成40不就行了?
select t1;
query.Dump();