views:

56

answers:

1

Hi,

I'm attempting to perform a DML operation against an Entity Framework model, specifically, an INSERT operation. My current eSQL string is:

INSERT INTO Contact (a, b, c) VALUES (1, 2, 3)

However, this triggers a runtime exception stating:

The query syntax is not valid. Near identifier 'INTO', line 1, column 8.

I'm having trouble tracking down eSQL examples using INSERT. Can anyone shed some light on this ?

Thanks

+2  A: 

AFAIK, Entity SQL can only be used to query an entity model. It doesn't provide a grammar for create, update, or delete operations.

pmarflee
Thanks for your response! I've found an example that uses a stored procedure, so you can do DML stuff with eSQL...I just want to be able to pass it a specific string instead of a stored procedure.
Scott Davies
Whoops. Just e-mailed a colleague and it turns out you're correct. Thanks!
Scott Davies
@Scott Davies: From MSDN (http://msdn.microsoft.com/en-us/library/bb738573.aspx) - 'Entity SQL currently provides no support for DML statements (insert, update, delete)'
pmarflee
@pmarflee - thanks! I found something similar in a Microsoft blog, but it was 2007 and therefore EF 1.0, so I ignored it, but your link looks up to date.
Scott Davies
@Scott Davies: the link I provided is for EF 1.0. The documentation for the forthcoming EF 4.0 release also states that DML operations are not supported, so it looks like Microsoft have no immediate plans to roll these features into the eSQL language.
pmarflee