Storing expression references to data base
Posted
by Marcus
on Stack Overflow
See other posts from Stack Overflow
or by Marcus
Published on 2010-03-13T09:20:54Z
Indexed on
2010/03/13
9:25 UTC
Read the original article
Hit count: 334
I have standard arithmetic expressions sotred as strings
eg. "WIDTH * 2 + HEIGHT * 2"
In this example WIDTH and HEIGHT references other objects in my system and the literals WIDTH and HEIGHT refers to a property (Name) on those objects.
The problem I'm having is when the Name property on an expression object changes the expression won't match anymore.
One solution I came up with is to instead of storing
"WIDTH * 2 + HEIGHT * 2"
i store
"{ID_OF_WIDTH} * 2 + {ID_OF_HEIGHT} * 2"
And let my parser be able to parse this new syntax and implement an interface or such on referenced objects
IExpressionReference
{
string IdentifierName { get; }
}
Anyone have a better/alternative solution to my problem?
© Stack Overflow or respective owner