Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.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# 使用Serenity.is temp为用户表筛选查找编辑器_C#_Serenity Platform - Fatal编程技术网

C# 使用Serenity.is temp为用户表筛选查找编辑器

C# 使用Serenity.is temp为用户表筛选查找编辑器,c#,serenity-platform,C#,Serenity Platform,我在用户的表中添加了UserType列 我在单位表上引用了用户表 我在UnitsRow上添加了LookUpScript,如下所示: [DisplayName("Lecturer"), NotNull, ForeignKey("[dbo].[Users]", "UserId"), LeftJoin("jLecturer"), TextualField("Lecturer")] [Lo

我在用户的表中添加了UserType列

我在单位表上引用了用户表

我在UnitsRow上添加了LookUpScript,如下所示:

[DisplayName("Lecturer"), NotNull, ForeignKey("[dbo].[Users]", "UserId"), LeftJoin("jLecturer"), TextualField("Lecturer")]
        [LookupEditor(typeof(UserRow), FilterField = "UserType", FilterValue = UserTypes.Lecturer)]
        public Int32? LecturerId
        {
            get { return Fields.LecturerId[this]; }
            set { Fields.LecturerId[this] = value; }
        }
[EnumKey("SmartAttendance.UserTypes")]
public enum UserTypes
{
    [Description("Admin")] Admin = 1,
    [Description("Lecturer")] Lecturer = 2,
    [Description("Student")] Student = 3
}
UserType的类型为enum,如下所示:

[DisplayName("Lecturer"), NotNull, ForeignKey("[dbo].[Users]", "UserId"), LeftJoin("jLecturer"), TextualField("Lecturer")]
        [LookupEditor(typeof(UserRow), FilterField = "UserType", FilterValue = UserTypes.Lecturer)]
        public Int32? LecturerId
        {
            get { return Fields.LecturerId[this]; }
            set { Fields.LecturerId[this] = value; }
        }
[EnumKey("SmartAttendance.UserTypes")]
public enum UserTypes
{
    [Description("Admin")] Admin = 1,
    [Description("Lecturer")] Lecturer = 2,
    [Description("Student")] Student = 3
}
但是,当我要添加新装置/编辑现有装置时,下拉列表为空。我在数据库中有3个用户,其中一个用户的类型是UserTypes


请告知我缺少的内容。

为讲座创建一个新的查找类(管理员、学生)

名称空间my.abc
{
使用Serenity.ComponentModel;
使用宁静数据;
使用Serenity.Web;
使用System.Linq;
使用BaseRow=Entities.UserRow;
[查找脚本]
公共密封类:RowLookupScript
{
私有静态BaseRow.RowFields fld=>BaseRow.Fields;
公共讲师
{
IdField=fld.Id.PropertyName;
TextField=fld.Userdetails.PropertyName;
}
受保护的覆盖无效准备(SqlQuery)
{
查询
.选择(fld.Id)
.选择(fld.user、fld.username、fld.UserTypes)
。其中(fld.UserTypes==2);
}
受保护的覆盖无效ApplyOrder(SqlQuery)
{
查询
.OrderBy(fld.username);在此处输入代码
}
}
}

IMHO向UserRow.cs中的UserType字段添加[LookupInclude]属性应该做到这一点


Hannes

请解释您的答案。很抱歉,我应该编写[LookupInclude]而不是[LookupEditor],我刚刚编辑了我的答案。使用FilterField和FilterValue的查找筛选是在客户端执行的,因此用于筛选的字段的数据必须包含在查找脚本中。这就是[LookupInclude]属性的作用。