Stored Procedures

Jan 7, 2010 at 9:16 AM

Is possible to work with stored procedures in Opf3?

How can i handle ? any sample.

Thanks.

Coordinator
Jan 8, 2010 at 1:03 PM

There are some classes in Opf3 that allow accessing stored procedures. They are not directly included i the chili.Opf3 project but part of a StoredProcedures project... In there you should also find additional documentation.

Jan 13, 2010 at 6:16 PM
Edited Jan 13, 2010 at 6:17 PM

As long as your stored procedure returns all of the fields within your persistent class then it's as easy as doing this

 

ObjectSet<WebUser> inactiveUsers = ObjectContextFactory.ObjectContext.GetObjectSet<WebUser>( new SqlQuery( "EXEC spGetInactiveWebUsers" ) );

 

Or if you just want to run a scalar stored procedure, then there's this method as well

 

SqlRawStorageAccess( ObjectContext.Storage as SqlStorageBase ).CreateCommand( new SqlQuery( "EXEC spDoWork") ).ExecuteNonQuery()

I've never done any advanced things such as retrieving return values etc. You may want to check out the project littleguru mentioned if you need more bells or whistles.