This project is read-only.

update or insert using altname

Apr 15, 2013 at 10:41 PM
i tried to do an insert and an update by using AltName for some fields in the entity. the generated sql does not take the AltName but the name of the field.

is this a bug?

thank you.
Apr 16, 2013 at 1:16 AM
Edited Apr 17, 2013 at 2:56 PM
No, this is not a bug.

The AltName only applies when querying a view to an object graph, and does not apply to inserts/updates (it is read only).

The intended purpose of the AltName is to allow you to setup an alternate mapping for use with views.
For example, if you had an ORDERS table and an ORDER_ITEMS table that both had a primary key column "ID".
Then you might have a view, "vOrders", that renamed one (or both) of those columns:

In this case you would specify AltName="OrderID" for your Order mapping, and AltName="OrderItemID" for your OrderItem mapping.

Then you run the view:
var orders = db.QueryToGraph<Order>("SELECT * FROM vORDERS");

And it will use the AltName mappings to map the renamed columns to the appropriate object/property.

Inserting and updating should ignore the AltName mapping and use the column instead.