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, Sorry if this is a simple question but I am trying to truncate a table in LightSpeed - 1 - What is the equivalent light speed way to access SQL directly? For example the "ExectuteCommand()" method in Linq to SQL.
2 - Is it possible to apply one model class to multiple identical tables with different names (to save a single table becoming too big)? Thanks for the great work! Jared |
|
|
1. We don't have a direct equivalent to ExecuteCommand. For loading entities, we have IUnitOfWork.FindBySql (3.0 or a 2.2 nightly build required), but this won't handle non-queries like a TRUNCATE. Probably the closest is IUnitOfWork.PrepareCommand, which you can use in conjunction with LightSpeedContext.DataProviderObjectFactory.CreateCommand: using (IDbCommand cmd = unitOfWork.PrepareCommand(context.DataProviderObjectFactory.CreateCommand())) Here the DPOF creates a command object of the appropriate type (e.g. SqlCommand, OracleCommand) and PrepareCommand associates it with the unit of work's connection and transaction if any. 2. No, I don't think this is possible. You could try doing something frighteningly ingenious with INamingStrategy and returning different table names based on the phase of the moon or whatever, but it would be very limited in the partitioning styles it could support, and I suspect alarmingly unstable. It would certainly not be able to aggregate across multiple tables. Hopefully you'll be able to get most of the scalability you need through indexing and other database-side optimisation techniques. |
|
|
Thanks Ivan, 1 - Perhaps this would be a nice and easy addition to the API in 3.0 so people familiar with L2S could pick up LightSpeed faster? 2 - Sounds unlikely, for now I'll use a single table and hope it doesn't become unwieldy. It is a eternally growing database (~6000 rows a day of data points) - so eventually I'll need multiple tables. Jared |
|