SPToCore
SPToCore copied to clipboard
Functions
extract Function as well
Hi ! Do you need to work with functions ? I've never used them in linToSql and I even don't know if they can be imported...
I have several databases where the DBA has created many user defined functions, including TVF and SVF.
I have no clue how to extract functions. However the following is what I hand coded. Perhaps getting the list of functions, and the return types and args could help generate this?
The Scalar Valued Functions look like this:
[DbFunction("FnGetPatternPositionColors")]
public static string FnGetPatternPositionColors(Nullable<long> patternId, Nullable<int> lightPositionId)
{
throw new NotSupportedException("Direct calls are not supported.");
}
The TVF's look like this:
public IQueryable<FnGetEscalationByTypeResult> FnGetEscalationByType(long escalationChainId, long escalationTypeId)
=>
Query<FnGetEscalationByTypeResult>().FromSqlInterpolated($"select * from FnGetEscalationByType({escalationChainId}, {escalationTypeId})");
and require this for the returned table
modelBuilder.Entity<FnGetEscalationByTypeResult>().HasNoKey();
Hi, I've checked and yes... The old LinkToSql supports user defined functions... To be honest, I've never had the necessity to use them in projects, I have used tons of stored procedure but zero functions...
If you can point me to the code that LinkToSql uses to interrogate the db I'll see if I can create a PR for you.
is this project available? https://github.com/DarioN1/SPToCore/blob/master/SPToCore.sln#L8