使用LINQ语句 [英] Working With LINQ Statements

查看:71
本文介绍了使用LINQ语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我有以下代码:

Hi friends,

I have a following Code:

var db=new LINQDataContext();
grid.datasource=db.table.where(c=>c.field1=="Value1" && c.field2=="Value2")


我需要在其中添加或删除条件,
我如何通过参数传递它们?例如在哪里使用SQL语句
我们可以定义一个字符串以传递条件.


I need to add or remove conditions to where,
how can i pass them by parameters?like Where SQL statements that
we can define a string to pass conditions.

推荐答案

这在您的C#代码中.所以你可以做的就像-
This is in your C# code. So what you could do would be something like -
var db=new LINQDataContext();
grid.datasource=db.table.where(c=>c.field1==""" + str2 + """ && c.field2==""" + str2 + """;)


其中str1 str2 将是像您的参数一样起作用的变量.


where str1 and str2 would be variables that would act like your parameters.


这篇关于使用LINQ语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆