Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain value and code in same object #1

Open
BHare1985 opened this issue Aug 11, 2015 · 1 comment
Open

Domain value and code in same object #1

BHare1985 opened this issue Aug 11, 2015 · 1 comment

Comments

@BHare1985
Copy link

Great client. I am considering modifying it to support Esri's new roads and highway extension to MapServers. (Supports queryAttributeSet which takes an LRS (Linear reference system) and queries multiple layers at once)

I ran into a use-case that I think could be useful to some, and that is getting the domain translated value and it's code both in the result. For example in the object model

        [Mapped("STATUS", "dStatus")]
        public virtual string StatusTranslated { get; protected set; }

        [Mapped("STATUS")]
        public virtual string StatusCode { get; protected set; }

Where dStatus is the domain for STATUS and StatusTranslated is the STATUS field with it's domain value and StatusCode is the code field of STATUS. Currently it errors out because I think duplicate mapping of STATUS. A few work arounds seem to exist to accomplish what I want, taking advantage of GetCodedValueByName in Esri but its internal, or using Service.Domains and do a lookup manually. Just thought this use-case may be an easy feature to add, although allowing multiple mappings this way may violate your design intent.

Thanks and keep up the great work.

@jshirota
Copy link
Owner

There's actually one more overload for the constructor that takes the
string formatter. If you put "Invalid code found: {0}", and your database
contains say 123, which is not a valid coded value domain key, this results
in "Invalid code found:123".

public Mapped(string fieldName, string domainName, string invalidCodeFormat
= null)

This is not an ideal solution. It should really be a delegate, but it's an
attribute class, so I couldn't put a delegate type in the constructor
argument. Anyway, Esri domain does not enforce referential integrity, so
we often end up with more work managing it. This automatic domain mapping
in PreStorm is provided mostly for one-way conversion (i.e. for reporting),
and in this case, the string formatter is good enough. If you're table is
guaranteed to never violate the domain, then, you could actually use this
for 2-way conversion and insert/update. This means, you assign the string
description to the property and invoke Update(), and the corresponding
domain key is stored in the table. However, I can't think of a situation
where you have to do this. It's almost better to deal with the key in the
database, and the human-readable description can come from a combobox,
which binds to the domain key value pairs.

On Tue, Aug 11, 2015 at 6:43 PM, Brian Hare [email protected]
wrote:

Great client. I am considering modifying it to support Esri's new roads
and highway extension to MapServers. (Supports queryAttributeSet which
takes an LRS (Linear reference system) and queries multiple layers at once)

I ran into a use-case that I think could be useful to some, and that is
getting the domain translated value and it's code both in the result. For
example in the object model

    [Mapped("STATUS", "dStatus")]
    public virtual string StatusTranslated { get; protected set; }

    [Mapped("STATUS")]
    public virtual string StatusCode { get; protected set; }

Where dStatus is the domain for STATUS and StatusTranslated is the STATUS
field with it's domain value and StatusCode is the code field of STATUS.
Currently it errors out because I think duplicate mapping of STATUS. A few
work arounds seem to exist to accomplish what I want, taking advantage of
GetCodedValueByName in Esri but its internal, or using Service.Domains
and do a lookup manually. Just thought this use-case may be an easy feature
to add, although allowing multiple mappings this way may violate your
design intent.

Thanks and keep up the great work.


Reply to this email directly or view it on GitHub
#1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants