Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用搜索操作项(如、大于、小于、介于…之间)搜索数据库实体_C#_Asp.net_Database_Architecture_Ado.net Entity Data Model - Fatal编程技术网

C# 使用搜索操作项(如、大于、小于、介于…之间)搜索数据库实体

C# 使用搜索操作项(如、大于、小于、介于…之间)搜索数据库实体,c#,asp.net,database,architecture,ado.net-entity-data-model,C#,Asp.net,Database,Architecture,Ado.net Entity Data Model,我在ado.net中使用搜索数据库的条件类。例如,对于数据库中的搜索用户,我使用UserSearchCriteria类使用“like”、“between”、“better-than”、“less-than”等操作数进行搜索。。。例如,搜索用户名包含、DisableCount大于和Id精确匹配等 当前搜索函数调用: var users = userManager.Search(new UserSearchCriteria() { Id = new Dictionary<int,

我在ado.net中使用搜索数据库的条件类。例如,对于数据库中的搜索用户,我使用UserSearchCriteria类使用“like”、“between”、“better-than”、“less-than”等操作数进行搜索。。。例如,搜索用户名包含、DisableCount大于和Id精确匹配等

当前搜索函数调用:

   var users = userManager.Search(new UserSearchCriteria() { Id = new 
   Dictionary<int,OperandTypeEnum>(1,OperandTypeEnum.ExactMatch),
   Username = new Dictionary<string, OperandTypeEnum>("John Doe",OperandTypeEnum.Like),
   DisableCount = new Dictionary<int, OperandTypeEnum>(5,OperandTypeEnum.GreaterThan)});
var users=userManager.Search(新UserSearchCriteria(){Id=new
字典(1,操作数类型枚举.ExactMatch),
用户名=新字典(“John Doe”,operantypeenum.Like),
DisableCount=新字典(5,OperationTypeEnum.GreaterThan)});
问题是,有没有更好的方法使用操作数进行搜索?因为简化的调用搜索功能会更好

public enum OperandTypeEnum
{
    ExactMatch=0, // default
    Like,
    GreaterThan,
    LessThan,
    Between
}

public class UserSearchCriteria
{
    public Dictionary<int?,OperandTypeEnum>  Id { get; set; }

    public Dictionary<string, OperandTypeEnum> Username { get; set; }

    public Dictionary<int, OperandTypeEnum> DisableCount { get; set; }
}
公共枚举操作数类型枚举
{
ExactMatch=0,//默认值
喜欢
比,
莱斯坦,
之间
}
公共类用户搜索条件
{
公共字典Id{get;set;}
公共字典用户名{get;set;}
公共字典禁用计数{get;set;}
}

如果此Id是该表的主键,则足以搜索排除其他参数。对于其他条件,如通过大于禁用计数的用户名获取,可以使用方法重载添加它们。如果您对这个答案不满意,我想我没有弄清楚您的问题,那么请您详细说明一下。Id实际上是一个示例属性。通常我使用非主键字段进行搜索。但对我来说,唯一的方法似乎也是超负荷的。