softfluent entity related method

107 Views Asked by At

I want to get the detail entity of a parent entity with a custom method in this method I want to sort the detail entity random and exclude the details by a condition it's possible in the parent method set the method for get the childs of the parent entity?

2

There are 2 best solutions below

0
On

In your example I have order and orderdetail like this:

OrderId = 1
date = 2015-06-01

Order detail
Order id = 1
Product = 1
RowNumber = 2

Order detail
Order id = 1
Product = 2
RowNumber = 3

I need that the order details shoul be order by rownumber in a random sort and I want that I get in the order object when I acces to the detail like Order.OrderDetails I get the orderdetails in random I have a method that returns the orderdetail in random but I don't set how set in the graphical design to set my method for get the orderdetails list collection. Other dude I try to add a cfl method for order random something like this in the order detail object

LOAD (int orderId) WHERE orderId = @orderId ORDER BY NEWID()     
SELECT * FROM table ORDER BY NEWID() 

and get a random order but I get and error so I add a partial class to order by random and add for example an product id like this a)2 b) 1

2
On

You can create a CFQL method with inline SQL:

<cf:method name="LoadByOrderRandom"
           body="LOAD(Order) where Order = @Order order by [newid()]" 
           checkLevel="None" />

More information about raw methods: http://blog.codefluententities.com/2014/07/03/cfql-raw-methods/