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
|
Hi Guys, Let's say I want to submit a plain MySQL query to get info about the table:
> show create table Test; how can I achieve this with LightSpeed ORM? Is that doable at all? To submit a query and get an array back?
Thanks, Dmitry |
|
|
If you want to materialise the results of the query into entities, then you can use IUnitOfWork.FindBySql. If you want non-entity values back, then there's not really much role for LightSpeed -- you're in the world of raw ADO.NET -- but you can use IUnitOfWork.PrepareCommand to quickly set your command up to run against the same database as LightSpeed, enroll it in the UOW's transaction, etc. |
|
|
can you pls post a simple sample? |
|
|
http://www.mindscape.co.nz/products/lightspeed/Help/html/M_Mindscape_LightSpeed_IUnitOfWork_FindBySql__1.htm |
|
|
The link no longer works? Is there documentation online for all the classes? It looks like the PrepareCommand function takes an IDbCommand as input, but there is no generic method to create one of those? It would be nice if there was an ADO.NET layer on top of the currently loaded driver that would abstract things somewhat so that we can create command to be processed by the underlying database without us having to have any knowledge of what that database is. As it stands right now, I would need to directly link to and create MySQL specific database objects in order to generate any direct SQL code, whereas it would be nice to be able to drop to SQL in a database independent manner. In the latest version of OpenAccess, they added just such an interface and implement ExecuteNonQuery, ExecuteQuery<TElement> and ExecuteScalar<TElement> so that you can do stuff in a database independent manner. Do you think something like that could be added to Lightspeed? |
|
|
The API docs are no longer online, but they still ship in the installer. IUnitOfWork.FindBySql is the method you need. The generic way to create ADO.NET objects is using LightSpeedContext.DataProviderObjectFactory. This allows you to create commands, parameters etc. for the data provider associated with the context, without needing to link to specific concrete implementations. See http://www.mindscapehq.com/documentation/lightspeed/Working-with-Database-Providers/Low-Level-Database-Access and the API docs for LightSpeedContext.DataProviderObjectFactory. |
|
|
One of the primary reasons the ADO.NET API that Telerik uses is useful is because it can hydrate objects for you, which is a large part of the complexity of using ADO.NET directly. I plan to build my own layer to do that (probably based on PetaPoco) if I end up using Lightspeed in our project. |
|