Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : OPath Queries : parameterising OPath queries

Date Post
10/31/2006 2:25:37 PM

Hi

I have an opath query as show below. How would i parameterise it please?

 

            OPath query query = new OPathQuery(typeof(SettingValue), " FormatList.FormatID = '" + formatID + "' && SettingID='" + settingID + "'");

many thanks

anndrea

11/2/2006 9:33:39 AM

Just replace each variable in your query with a question mark, like so:

OPathQuery query = new OPathQuery(typeof(SettingValue), "FormatList.FormatID = ? && SettingID = ?);

Then pass the values when you execute the query:

ObjectSet results = WormEngine.GetObjectSet(formatID, settingID);

- Jeff Lanning

11/8/2006 10:38:10 AM

OPathQuery query = new OPathQuery(typeof(SettingValue), "FormatList.FormatID == ? && SettingID == ?");

MyObjectSpaceObject.GetObjectSet(typeof(SettingValue), query, formatId, settingId);

or for .NET 2:

OPathQuery query = new OPathQuery<SettingValue>("FormatList.FormatID == ? && SettingID == ?");

MyObjectSpaceObject.GetObjectSet<SettingValue>(query, formatId, settingId);

12/21/2006 4:17:45 PM many thanks :)