I have a stored procedure named ParseXML in SQL Server. I have a repository pattern using LINQ to SQL. I need to call the stored procedure from within the repository layer.
You can do something like this, calling the method using reflection:
var inputXML = GetXML();
var method = Context.GetType().GetMethod("ParseXML");
if(method == null) throw new InvalidOperationException("Defined DataContext does not have method ParseXML");
var result = method.Invoke(Context, new object[]{ inputXML });
If you are using c# 4.0, you can do:
var inputXML = GetXML();
dynamic dynamicContext = Context;
var result = (ISingleResult)dynamicContext.ParseXML(inputXML);