I reproduced the problem by creating a small sample with an entity called Employee and an enum called EmployeeStatus. I then created a method called LoadByStatus. The problem is the first line of the method throws an exception when the enum parameter is set to employeed. There are other things wrong as I commented out the if statement and it generated a SQL exception.
public static System.Data.IDataReader PageDataLoadByStatus(CodeFluent.Runtime.PageOptions pageOptions, DemoLoadByEnum.EmployeeStatus status)
{
if ((status == DemoLoadByEnum.EmployeeStatus.Employeed))
{
throw new System.ArgumentNullException("status");
}
CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(DemoLoadByEnum.Constants.DemoLoadByEnumStoreName).Persistence;
persistence.CreateStoredProcedureCommand(null, "Employee", "LoadByStatus");
persistence.AddParameterEnumInt32("@status", status, DemoLoadByEnum.EmployeeStatus.Employeed);
if ((pageOptions != null))
{
System.Collections.IEnumerator enumerator = pageOptions.OrderByArguments.GetEnumerator();
bool b;
int index = 0;
for (b = enumerator.MoveNext(); b; b = enumerator.MoveNext())
{
CodeFluent.Runtime.OrderByArgument argument = ((CodeFluent.Runtime.OrderByArgument)(enumerator.Current));
persistence.AddParameter(string.Format("@_orderBy{0}", index), argument.Name);
persistence.AddParameter(string.Format("@_orderByDirection{0}", index), ((int)(argument.Direction)));
index = (index + 1);
}
}
System.Data.IDataReader reader = CodeFluentContext.Get(DemoLoadByEnum.Constants.DemoLoadByEnumStoreName).Persistence.ExecuteReader();
return reader;
}
Below is Employee entity
<cf:entity name="Employee" namespace="DemoLoadByEnum">
<cf:property name="Id" key="true" />
<cf:property name="Name" entityDisplay="true" />
<cf:property name="Status" typeName="{0}.EmployeeStatus" />
<cf:method name="LoadByStatus" body="LOAD(DemoLoadByEnum.EmployeeStatus status) WHERE Status = @status" />
</cf:entity>
Below is my Enum
<cf:enumeration name="EmployeeStatus" namespace="DemoLoadByEnum">
<cf:enumerationValue name="Employeed" />
<cf:enumerationValue name="Released" />
</cf:enumeration>