Print Page | Close Window

Help PassthruEsqlQuery

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2163
Printed Date: 10-Jun-2026 at 8:46pm


Topic: Help PassthruEsqlQuery
Posted By: Molinari
Subject: Help PassthruEsqlQuery
Date Posted: 16-Sep-2010 at 8:01am
Hey

I wonder if it's possible to perform a DELETE this way


PassthruEsqlQuery query = new PassthruEsqlQuery(typeof(PESSOA_TIPO_USUARIO_P_RIGHT),
               "DELETE FROM PESSOA_TIPO_USUARIO_P_RIGHT WHERE FK_PESSOA_TIPO_USUARIO_PERFIL = 1);

query.ExecuteAsync(op =>
{
   if (!op.HasError)
       return;
   else
      MessageBox.Show(op.Error.Message);
});

Thanks



Replies:
Posted By: DenisK
Date Posted: 16-Sep-2010 at 7:45pm
Hi Molinari;

Entity SQL provides no support for DELETE statement at this time. Please see Microsoft's website below to find out how Entity SQL differs from Transact-SQL.

http://msdn.microsoft.com/en-us/library/bb738573.aspx - http://msdn.microsoft.com/en-us/library/bb738573.aspx


Posted By: Molinari
Date Posted: 17-Sep-2010 at 5:12am
OK... Denisk

Thanks...


Posted By: Molinari
Date Posted: 17-Sep-2010 at 9:55am
Hi Denisk...

You have some idea.
to resolve this?

thanks...


Posted By: DenisK
Date Posted: 17-Sep-2010 at 10:21am
My suggestion is to use our EntityManager.RemoveEntity and .RemoveEntities.


Posted By: Molinari
Date Posted: 17-Sep-2010 at 11:19am

I do not want to search all the data
so i can delete, I want delete without search.

using your suggestion, I can do this?

Thanks Denisk....



Posted By: DenisK
Date Posted: 17-Sep-2010 at 11:46am
I think this post can help you get some idea on how you can do that.

http://omaralzabir.com/linq_to_sql__delete_an_entity_using_primary_key_only/ - http://omaralzabir.com/linq_to_sql__delete_an_entity_using_primary_key_only/


Posted By: Molinari
Date Posted: 17-Sep-2010 at 12:15pm
I have no idea, because EntityManager does not has ExecuteCommand or something like method in DevForce2010.

And using PassthruEsqlQuery I am not getting sucess;

thanks...


Posted By: DenisK
Date Posted: 17-Sep-2010 at 12:37pm
This approach is generally not recommended and you have to write a work around function that involves writing a wrapper around a Transact-SQL statement. ExecuteCommand is a .NET namespace. Please see below for more info.

http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.executecommand.aspx - http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.executecommand.aspx


Posted By: DenisK
Date Posted: 17-Sep-2010 at 1:19pm
Another approach is to invoke a server method using the DF InvokeServerMethod. Inside that server method, you will need to create an ADO.NET connection using the connection string from the config file as well as creating the command objects and execute the DELETE SQL statement.



Print Page | Close Window