Вопрос

I'm currently using CodeFluent Entities and I want to generate a text-based report that prints some statistics about my current model.

The Template Producer meets all my expectations but I've some problems while using Linq extension methods :

[%@ namespace name="System.Linq" %]

[%= Producer.Project.Entities.Where(entity => entity.IsLightWeight).Count() %]

I have the following error message : The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missin an assembly reference?).

Is there a way I can refer other assemblies from a CodeFluent Entities template file ?

Это было полезно?

Решение

You can add template directive at the beginning of the template file in order to add assemblies and namespaces.

[%@template language="CSharp" providerOptions="CompilerVersion=v3.5" %]
[%@ Reference name="C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" %]
[%@ namespace name="System.Linq" %]

Другие советы

Add reference in your .cs file

using System.Linq;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top