让与将用于筛选结果字符串列表开始:获取SQL LINQ结果
List<String> RadioNames = new List<String>();
RadioNames.AddRange(new String[] { "abc", "123", "cba", "321" });
我希望能够基于LINQ筛选到SQL数据库表在RadioNames
,但赶上是我想RadioNames
是部分匹配(这意味着它将捕获Radio123,而不仅仅是123)。
,我需要过滤的源代码如下:
var ChannelGrants = from cg in sddc.ChannelGrants
select new
{
cg.ID,
cg.Timestamp,
cg.RadioID,
cg.Radio
};
所以我需要执行类似下面(外原ChannelGrants
结果,因为这是一个条件搜索)
if(RadioNamesToSearch != null)
{
List<String> RadioNames = new List<String>();
// Here I split all the radio names from RadioNamesToSearch based on a command separator and then populate RadioNames with the results
ChannelGrants = from cg in ChannelGrants
where ???
select cg;
}
我需要帮助吗?在上面的代码中(或者如果ChannelGrants = ...
一起无效)。重复上面,我需要过滤ChannelGrants
返回从RadioNames
任何匹配,但它会做部分匹配(这意味着它将捕获Radio123,而不仅仅是123)。
所有的代码被包含在作为这样的方法,...
public static DataTable getBrowseChannelGrants(int Count = 300, String StartDate = null, String StartTime = null, String EndDate = null, String EndTime = null, String RadioIDs = null, String RadioNamesToSearch = null, String TalkgroupIDs = null, String TalkgroupNames = null, bool SortAsc = false)
'RadioNames'和'RadioNamesToSearch'有什么区别?后者从哪里来?你还没有在任何地方宣布它。 –
对不起,我编辑了我的帖子以显示代码所包含的方法。我省略了大部分270行代码以提高可读性。 –
对此有何更新? – seekerOfKnowledge