Hi there,

  I have a couple of tables that have a few fields that are the same
and I do some common operations on both the tables.  To try and
minimise code duplication I created an interface that declared these
common fields and applied the interface to both table classes.

  This let me create a Generic function that did the query I wanted to
do.  As a simplified example:

private static IEnumerable<T> PrefixMatch<T>(this IQueryable<T> query,
string searchValue) where T : IRoutingGroupLookup
{
   var lookups = query.Where(l => (l.LookupType ==
RoutingLookupType.Prefix)).OrderByDescending(l =>
l.LookupValue.Length);

  return lookups;
}

  And the code to use it:

MyDb db = new MyDb(conn);
db.InboundRoutingGroupLookups.PrefixMatch(myPrefix).FirstOrDefault();
db.OutboundRoutingGroupLookups.PrefixMatch(myPrefix).FirstOrDefault();

  When trying to run the query, DBLinq throws an ArgumentException in
SqlProvider.GetLiteral(...).  The operation type it's trying to do is
a MemberAccess in the where clause.  If I replace the generic function
with two identical functions that use the actual table classes then it
all works ok.  I tried looking through the source code but couldn't
work out where the Expression creation wasn't recognising the member
as a table column.

  Is it possible to do this kind of thing?  If so, if anyone could
give me some pointers on where I should look they'd be gratefully
received!

    Best Regards,

         Matt.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to