Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XSLT - Using C# Function and Entity Framework

$
0
0

Hi,

I have a number of functions in an xsl file that all work ok. They are basic C# functions.

Now I need to create a method that uses Entity Framework to return data from SQL Server table.

However, when I add it into the xsl functions I get error...

Error 1 Metadata file 'myAssemblyName.dll' could not be found 

Below is my code...

<msxsl:script language="C#" implements-prefix="userCSharp"><msxsl:assembly name="System.Core" /><msxsl:using namespace="System.Linq" /><msxsl:using namespace="System.Collections.Generic" /><msxsl:assembly name="myAssemblyName" /><msxsl:using namespace="myAssemblyNamespace" /><![CDATA[
public string GetMappingValue(string name, string value)
{
    using (Entities entities = new Entities())
    {
        try
        {
            List<MappingValue> mappedValues = (from c in entities.GetMappedValue(name, value)
                                                select c).ToList();

            return mappedValues[0].ValidValue;
        }
        catch (Exception exception)
        {
            _logger.Error("An exception occurred while getting value.", exception);
            throw;
        }
    }
}

Thanks!


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>