Serenity: difficulty while Binding Enum fields

Created on 7 Oct 2017  路  6Comments  路  Source: serenity-is/Serenity

@volkanceylan ..
this my enum declaration
public enum Status
{
Open,
RequiresClarification,
Working,
Closed,
Converted,
projectClosed
}

I want Enum on this Field..
[DisplayName("Status"), Size(50)]

    public string Status
    {
        get { return sFields.Status[this]; }
        set { Fields.Status[this] = value; }
    }

All 6 comments

@ANDY7575 , according serenity's guide ( https://volkanceylan.gitbooks.io/serenity-guide/tutorials/movies/adding_a_movie_kind_field.html ), I think that you need set the Field Status like Enum Status, not string.

something like

_public Status? Status_

note.: BestPratice: rename your enum to _ProjectStatus_, and then set it on field

_public ProjectStatus? Status_

Yes, an enum is integer value. You must define

    public Status? Status
    {
        get { return (Status?)sFields.Status[this]; }
        set { Fields.Status[this] = (Int32?)value; }
    }

and field

public Int32Field Status;

Hello @rolembergfilho
i tried all same from serenity guide but still giving error as i am unable to Transform T4 template
it is giving error,as below*
Error =
Severity Code Description Project File Line Suppression State
Error An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find file 'E:\0. Development[DO NOT DELETE]\0. ProjectS\A_Project Managment_InHouse\Web_DSL\Web_DSL\Web_DSL.Web\bin\DSL.Web.dll'.
File name: 'E:\0. Development[DO NOT DELETE]\0. ProjectS\A_Project Managment_InHouse\Web_DSL\Web_DSL\Web_DSL.Web\bin\DSL.Web.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Enumerable.<UnionIterator>d__661.MoveNext()
at System.Linq.Enumerable.d__661.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at System.Collections.Immutable.ImmutableArray.CreateRangeT
at Microsoft.CodeAnalysis.Compilation.ValidateReferencesT
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable1 newReferences) at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation() at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile() at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable1 references, Boolean debug, SupportedLanguage language, String compilerOptions) 1

@Estrusco i have done all change u guys suggested ,
@rolembergfilho
still when opening Dialog for Status Field its giving error as below..
0x800a139e - JavaScript runtime error: Can't find Common.Enum.ProjectStatus enum type!

Compile solution, execute T4 transformation. See if you have error in typescript output. Also see, in ServerTypings if you have the .ts file of your enum.

Check your xyzForm.cs and see if field Status is Int32 or type enum Status

hello
@rolembergfilho
@Estrusco
thank you guys .
all above issues are resolved...
it just because i had made some silly mistakes in server.tt

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newyearsoft picture newyearsoft  路  3Comments

Amitloh picture Amitloh  路  3Comments

Akarsh03 picture Akarsh03  路  3Comments

StefanTheiner picture StefanTheiner  路  3Comments

ahsansolution picture ahsansolution  路  3Comments