AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

BuildWhereStatement with IGeneratedCriteria as parameter instead of bag on ADOHelper class #683

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I did not find another place to comment you this...

On the ADOHelper class it will be usefull to have an overload funcion (to not 
break existing code) of BuildWhereStatement with IGeneratedCriteria as 
parameter, to include the full table name on the where clause. This is useful 
when overriding the select statement in "OnFetching" where you could include 
join(s) with another table(s) that might have the same column names been used 
as part of the criteria.

    Public Shared Function BuildWhereStatement(criteria As IGeneratedCriteria) As String
     If criteria isnot nothing then
        Dim bag As Dictionary(Of String, Object) = criteria.StateBag
        If bag.Count = 0 Then
            Return String.Empty
        End If
        Dim columnNames As String = bag.Keys.Aggregate(String.Empty, Function(current, columnName) current + String.Format(criteria.TableFullName & "." & "[{0}] = @p_{0} AND ", columnName))
        Return String.Format("WHERE {0}", columnNames.Remove(columnNames.Length - 5, 5))
    else
       Return String.Empty
     End If
    End Function

Thanks

Original issue reported on code.google.com by yoselsua...@gmail.com on 6 Mar 2013 at 11:15

GoogleCodeExporter commented 9 years ago
Issue 684 has been merged into this issue.

Original comment by bniemyjski on 7 Mar 2013 at 10:39

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 16 Apr 2013 at 1:33