Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Using ExpressionToApply with UpdateEntitiesDirectly
 

Pages: 1
LLBLGen Pro Runtime Framework
Using ExpressionToApply with UpdateEntitiesDirectly
Page:1/1 

  Print all messages in this thread  
Poster Message
saggett
User



Location:
Manchester, UK
Joined on:
12-Nov-2007 15:44:46
Posted:
50 posts
# Posted on: 21-Nov-2008 15:38:22.  
Running v2.6, C#, Adapter pattern, compiling for .NET 3.5:

I've been trying to write an expression for use in a call to UpdateEntitiesDirectly. However I can only produce the expression I want by writing it as a DbFunctionCall, like so:

Code:

var adapter = new DAL.DatabaseSpecific.DataAccessAdapter();
var bucket = new RelationPredicateBucket();
bucket.Relations.Add(SpecialPriceEntity.Relations.ProductEntityUsingProductId);
var spUpdate = new SpecialPriceEntity();
spUpdate.Fields[(int) SpecialPriceFieldIndex.IsSentToBaan].ExpressionToApply =
    new DbFunctionCall("CASE {0} WHEN 'TRUE' THEN NULL WHEN 'FALSE' THEN 'FALSE' END", new object[] {ProductFields.IsQonly});
adapter.UpdateEntitiesDirectly(spUpdate, bucket);


Is there any way I can write it using the LLBLGen Expression syntax, something like:

Code:

var adapter = new DAL.DatabaseSpecific.DataAccessAdapter();
var bucket = new RelationPredicateBucket();
bucket.Relations.Add(SpecialPriceEntity.Relations.ProductEntityUsingProductId);
var spUpdate = new SpecialPriceEntity();
spUpdate.Fields[(int) SpecialPriceFieldIndex.IsSentToBaan].ExpressionToApply =
    (ProductFields.IsQonly == true ? DbNull.Value : false);
adapter.UpdateEntitiesDirectly(spUpdate, bucket);


As this is a lot more readable and easier to maintain.
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8099 posts
# Posted on: 21-Nov-2008 19:26:14.  
Hi saggett,

That's no possible directly, as no mapping exists between the ternary construct and some sql query text. The default expression usage for updates are addressed here.

You have two options:

A. Write two update actions with different filters: one for ProductFields.IsQonly == true and one for ProductFields.IsQonly == false.

B. Use your DBFunctionCall approach.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


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

Version: 2.1.12172008 Final.