Hossein Moradinia
Hossein Moradinia

Reputation: 6244

Handling and calculate the formula saved in the database

The following link descrip about Non-Relational field types in database: http://wiki.developerforce.com/page/An_Introduction_to_Force_Database

one of field types is the formula fields:

Formula - A read-only field holding data generated from a formula expression.

I use c# and entity framework as development tools.Business logic in this application will be changed over months.I want to let system administrators(some users) to define application 's formula and store in the database. My Question: How can is calculate formulas ,stored in database dynamically with c#?! (formula contains: static values,field names,functions,operators and ...).

What are your ideas?

Upvotes: 2

Views: 2018

Answers (1)

Wouter de Kort
Wouter de Kort

Reputation: 39898

Two options come to mind:

  • If the operations are fairly simple you can have a look at the new Roslyn CTP. Roslyn is a new managed compiler for Visual Studio that you can use in your own code. It let's you easily compile snippets of code and execute them.
  • Another thing you can have a look at are Expression Trees. With the Expression Tree Serializer you can serialize an expression tree and possible save it in a database. But then you will need some kind of user interface to construct those expression trees. On the MSDN you can find some examples of how to construct an expression tree by hand

Upvotes: 3

Related Questions