This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello at all, i've got a class that reads values out of my database. These class has got some overloaded functions. For example: public void readTableXY(int Id) { using (var sqLiteWorksapce = _SQLiteContext.CreateUnitOfWork()) { var Table = sqLiteWorksapce.TraceSimSipAccounts.Single(p => p.Id == Id); Console.WirteLine(Table.Id); Console.WirteLine(Table.Name); //Just for example } }
so i can give the needed id into my function and the function is able to handle with the appropriate row with the help of my variable "Table".
What can i do to have a little bit more dynamic in my class without having hundreds of functions for each event. For example: readTableXY( every item of "name"); or maybe: readTableXY( every item of "id" where "id" is > 200);
I hope you know what i mean, because i think my english is not the best...:) |
|
|
You have a couple of options: 1. Use LightSpeed QueryExpression objects. So your readTableXY could take a QueryExpression parameter: public void readTableXY(QueryExpression criteria) { and your users could call it like this: readTableXY(Entity.Attribute("Id") > 200 && Entity.Attribute("Name") != "Paul"); 2. You can use LINQ Expression objects. In this case your readTableXY would take an Expression<Func<TraceSimSipAccount, bool>> parameter, and pass it to a Where clause: public void readTableXY(Expression<Func<TraceSimSipAccount, bool>> criteria) { and your users would call it like this: readTableXY(a => a.Id > 200 && a.Name != "Paul"); |
|