0

I have a user defined function in sql server that returns a string. I want to add this as a property to my class in linq to sql dbml file. My Class represents a view in sql server. (Note, I don't want to add this UDF to the view)

I've tried to create a property manually and then assign the source as the name of my UDF in sql server. Doesn't like this and errors.

Is what I'm doing possible? thanks

1 Answer 1

2

You can only map a client method defined on a class to a user-defined function by using the FunctionAttribute attribute.

But you can wrap your function in your class with property

CREATE FUNCTION Test(@string varchar(100))
RETURNS varchar(100)
AS
BEGIN
    RETURN "Test"
END

[Function(Name = "Test", IsComposable = true)]
[return: Parameter(DbType = "VarChar(100)")]

public string Test([Parameter(Name = "string",
    DbType = "VarChar(100)")] string @string)
{
    return ((string)(this.ExecuteMethodCall(this,
        ((MethodInfo)(MethodInfo.GetCurrentMethod())),
        @string).ReturnValue));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.