Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> CallBack and UnitOfWork
 

Pages: 1
Bugs & Issues
CallBack and UnitOfWork
Page:1/1 

  Print all messages in this thread  
Poster Message
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1112 posts
# Posted on: 06-May-2015 17:55:40.  
Using self servicing and version 4.2

Your examples show using callbacks that do not have a transaction parameter as the last parameter:
Code:
// C#
UnitOfWork uow = new UnitOfWork();
uow.AddCallBack(new ActionProcedures.ClearTestRunDataCallBack(ActionProcedures.ClearTestRunData),
    UnitOfWorkCallBackScheduleSlot.PreEntityDelete, true, _testRunID);



The generated call back routines that I get DO have Transaction as the last parameter.

1) Should I pass null into the 'CallBack' for the transaction and when UoW makes the call it will provide the real transaction (if true is passed in for use transaction)?
2) Why do your examples and in the forum show use of the CallBack where a transaction is not provided - meaning the code generated is different than what I get?

SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1112 posts
# Posted on: 06-May-2015 18:00:02.  
Grrr...misreading the docs, over and over again...
Never mind....dunno what I was thinking....

The real problem is the ActionProcedure has ref parameters, which you cannot use on params. So not sure what to do.


Maybe you could consider a simple lambda expression to be provided as the callback - you can provide the transaction object as a parameter...then we dont need code generated or anything.


SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1112 posts
# Posted on: 06-May-2015 18:01:57.  
Maybe:

Code:

unitOfWork.AddCallBack(UnitOfWorkCallBackScheduleSlot.PostEntityDelete,
trans=> ActionProcedures.MyProc(2,34,3,trans) );


That would be much simpler to use and resolve my ref issue...
SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14498 posts
# Posted on: 07-May-2015 00:14:48.  
You can use your own delegate and method in which you call the SP.
Example here: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=20782&StartAtMessage=0&#117091


  Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1112 posts
# Posted on: 11-May-2015 16:44:31.  
Right. Delegates - completely unused anywhere now that we have lambdas!

Feature request - can you please add/forward to team?
SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37561 posts
# Posted on: 12-May-2015 09:33:08.  
the delegates are predefined, and I don't see why they are so horrible to use?

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1112 posts
# Posted on: 12-May-2015 14:45:39.  
It is just much easier to use the lambdas. With the introduction of Lambdas no one uses or needs delegates anymore.

SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37561 posts
# Posted on: 12-May-2015 17:23:29.  
WayneBrantley wrote:
It is just much easier to use the lambdas. With the introduction of Lambdas no one uses or needs delegates anymore.

No that's not true. Delegates are often used in apis, as they dictate method signatures. The thing is that with ref parameters, the value returned has to end up somewhere, and a lambda doesn't cut it, as where is the value going? So you have to supply your own method which calls the proc.

Anyway, delegates and lambda's are close friends Regular Smiley
I can do this:
Code:
UnitOfWork2 uow = new UnitOfWork2();
ActionProcedures.ClearTestRunDataCallBack del = (a,b)=>ActionProcedures.ClearTestRunData(a, b);
uow.AddCallBack(del, UnitOfWorkCallBackScheduleSlot.PreEntityDelete, true, new object[1] { _testRunID });


Here I define a lambda, and assign it to a variable which has as type the delegate to pass. Then I pass the delegate to the AddCallBack, et viola Regular Smiley

Equivalent without a lambda:
Code:
UnitOfWork2 uow = new UnitOfWork2();
uow.AddCallBack(new ActionProcedures.ClearTestRunDataCallBack(ActionProcedures.ClearTestRunData), UnitOfWorkCallBackScheduleSlot.PreEntityDelete, true, new object[1] {_testRunID});


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.