我有一个名为StatusTypes的枚举类型
public enum StatusTypes
{
Open = 1,
Allocated = 2,
WorkInProgress = 3,
WaitingOnRequestor = 4,
WaitingOnThirdParty = 5,
Monitoring = 6,
Testing = 7,
OnHold = 8,
Complete = 9,
SignedOff = 10,
Reopened = 11
}
Run Code Online (Sandbox Code Playgroud)
我正试图在我的存储库中使用它....
public IQueryable<Incident> GetAllOutstandingIncidents()
{
return from i in db.Incidents
where i.Status != Types.StatusTypes.SignedOff && i.Status != Types.StatusTypes.Complete && i.DeletedDateTime != null
orderby i.DueDateTime
select i;
}
Run Code Online (Sandbox Code Playgroud)
...然后在我看来使用它......
<tbody>
<% foreach (var incident in Model.TotalIncidentsOutstandingList) { %>
<tr>
<td><%: incident.IncidentID %></td> …Run Code Online (Sandbox Code Playgroud) 如何使用C#将Linq中的字符串转换为枚举?
下面的类型转换是否也适用于linq?:
(Audience)Enum.Parse(typeof(Audience), value, true);
Run Code Online (Sandbox Code Playgroud)
如果是,请告诉我如何使用它?