Yes, it does....that is much better. (I think this confirms the need for a blurb in the docs!
)
For the record:
I generate a file called SqlFunctionCalls.cs that generates:
1) a CachedDbFunctionCall class that I use for all my functions. Remember this class lets it cache the text from a function call - so you can reuse parameters in multiple parts of the sql so SQL Server does not give errors.
2) a partial class SqlFunctionFactory that contains:
public static object GetScalar(IExpression expressionToApply, ITransaction transaction) - this is a wrapper around dao.GetScalar so you can easily get the result of a function.
and it contains all the SQL Server date and string built in function wrappers, like:
public static IExpression GetDate()
{
return new CachedDbFunctionCall("GETDATE", null);
}
(Which I sent to you and you posted in user section)
I then extend the partial class of SqlFunctionFactory to add in my custom function calls all returning IExpressions. I overload them so they take the actual parameter types as well as object parameter types. This way I can pass in an EntityField or the actual value.
Additionally I add easy functions to call to just get the return value of the function, like:
public static bool IsDemoCompany(int companyId, ITransaction transaction)
{
return (bool)SqlFunctionFactory.GetScalar(SqlFunctionFactory.IsDemoCompany(companyId), transaction);
}
and now, I added this class:
public partial class SqlFunctionForPredicate
{
private SqlFunctionForPredicate()
{
}
public static EntityField IsDemoCompany(object companyId)
{
return new EntityField("IsDemoCompany", SqlFunctionFactory.IsDemoCompany(companyId));
}
public static EntityField IsDemoCompany(int companyId)
{
return new EntityField("IsDemoCompany", SqlFunctionFactory.IsDemoCompany(companyId));
}
}
Anyway, all this seems to work pretty well for me and enables me to use functions quite easily...
Man, I wish I had the meta-data so I could just generate this ALL without writing this code