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, We are considering using LightSpeed for our project and have the following questions - 1. From the LightSpeed documentation it mentions that the Repository class is a static class representing the LightSpeed implementation of the well-known Repository pattern. I would like to know if there's a sample code showing how to interact with the Respository object that LightSpeed uses internally. 2. Does LightSpeed supports importing domain models created in other softwares like Visio/Altova UModel etc.? We have already created the domain model using Altova Umodel and the domain objects are already created. I know that LightSpeed supports generating the DTO's from the lightspeed domain model, but in our scenario that would mean we have to recreate the whole model. Is there an alternative way so that we can refer our domain objects project (class library with the entities) and generate the DTO's in LightSpeed? Thanks, |
|
|
1. Hmm, could you point us to where you found that? The static Repository class existed in LightSpeed 1 but has since been removed in favour of the IUnitOfWork interface, but it sounds like we missed a reference in the docs. The LightSpeed download includes several samples of working with the IUnitOfWork interface -- just open the Samples solution from the Start menu. 2. At the moment we only support import from LINQ to SQL, but we'd be happy to look at building a UModel importer as long as UModel uses a human-readable file format (self-explanatory text file or XML). Send me your UModel model (ivan @ the obvious domain name) and I'll get back to you on the feasibility of this. Alternatively, the .lsmodel format is simple XML so you could probably write a file converter yourselves without too much trouble; and ultimately all LightSpeed entities are defined in C# or VB so if UModel supports code generation you could create your own templates and work directly in UModel if that's what you prefer. |
|
|
Thanks for your reply Ivan. 1. You're right. I initially googled on LightSpeed and repository pattern and came across this link - http://www.mindscape.co.nz/help/ls1/Help%20Topics/ArchitecturePatterns.html Later when I saw the version 3.0 documentation that I've got installed, it mentiones only about the the IUnitOfWork Interface. Does this interface provides all capabilities that was earleir provided by Repository object and conforms to the Repository pattern usage in general? 2. I will try to send you a sample UML model created in UModel. We haven't thought of writing any file convertors yet will and also need to check if UModel supports code generation. Thanks, |
|
|
IUnitOfWork provides all the services that used to be on Repository except for lifecycle management. The Repository class used to handle units of work automatically, but these are now explicit. The lifecycle management services have been moved to unit of work scope classes, specifically PerRequestUnitOfWorkScope. There is also a RepositoryBase class that you can use to create your own repository facades but it's not required -- my impression is that most people either write their own or just use the LINQ strong-typed unit of work class (e.g. StoreUnitOfWork) as their repository class (because this already provides the domain-specific collection-style usage pattern, via properties such as .Products, .Customers, etc.) and don't bother with a separate repository class -- the strong-typed UOW is pretty close to the Repository pattern already. |
|
|
Hi, I am revisiting this thread as I have a new requirement in terms of using Lightspeed in our app. Basically, we already have the entity classes created for the domain. Now considering I'm not using the Lightspeed designer, is there a way I could use Lightspeed using - 1. IUnitOfWork interface 2. Create database tables using any command line / other tools, like in fluent nhibernate It's critical for me to have some kind of workaround using lightspeed in the above scenarios (where we already have the domain layer and entity classes), before I select Lightspeed as the choice of ORM. Thanks, |
|
|
So you've written LightSpeed entity classes by hand, and now you want to generate the database tables from those? We have *experimental* tools for this, but they have a number of limitations and have not been exhaustively tested, so should be treated with caution. These tools are: lsgetmodel: creates a .lsmodel file from a compiled assembly (this is known to have limitations and to struggle with complex domain models) lsupdate: updates a database schema from a .lsmodel file You can find these in the Tools/Designer folder. By using them together, you can update a database schema from a compiled assembly. Note that these are *design-time* tools. If you want to update the database schema at runtime, then you should use LightSpeed 3 migrations. However, we only generate migration code from the designer, but you can create migrations by hand; or you could use lsgetmodel to create a designer file, then use the designer to generate the migrations, then throw away the designer file. |
|
|
Ivan, Thanks for your reply. I created a very basic sample using a few classes and ran the lsgetmodel tool. The tool returned to command prompt saying the path of the lsmodel file, but when I tried opening the model I saw an empty model generated. Can you let me know your email address so that I can zip the sample and send it across to you? Also, our actual application will have complex scenarios with inheritence hierarchy and I found that all Lightspeed generated code inherits from the Entity class (not an Interface and C# doesn't supports multiple inheritence). Do you think this can be a probelm while generating lsmodel for classes under these scenarios? Thanks, |
|
|
My email is ivan @ the obvious domain name. All LightSpeed entities, whether generated or hand-written, must inherit from the Entity<T> class. This is in fact how lsgetmodel identifies which of your classes are LightSpeed entities and which are not. |
|
|
Ivan, I have sent you an email yesterday from my gmail account (biplabbanerjee75@gmail.com) with an attached sample code at your email address ivan@mindscape.co.nz. Not sure if you've got chance to go through it. I appreciate if you can respond to the email. Let me know if you haven't received the email otherwise. Thanks, |
|
|
Hello Biplab, Yes, I've received the email -- thanks for putting that together. I haven't had a chance to investigate the problem yet though -- I'll keep you informed. |
|
|
Hello Biplab, This was an issue with lsgetmodel and lsupdate. There is a fix in the next nightly build (7 Apr 2010), available from about 1500 GMT. Please note that you will need to rebuild your test assembly against the updated LightSpeed assembly before running lsgetmodel against it. Thanks for alerting us to this issue and please let us know if you still run into problems. |
|
|
Hi, I am able to generate the model using lsgetmodel after installing the nightly build, but I once the model is generated and I add it to the project, I get the following compile time error - Error 1 Missing partial modifier on declaration of type 'LSModelImportTest.Product'; another partial declaration of this type exists D:\VS_2008_Projects\LSModelImportTest\Product.cs 8 18 LSModelImportTest because lsgetmodel also generated a class called "Product" as public partial class Product : Entity<int>
when I put the partial keyword in my original entity class like public partial class Product : AbstractEntity I get this error Error 1 Partial declarations of 'LSModelImportTest.Product' must not specify different base classes D:\VS_2008_Projects\LSModelImportTest\Product.cs 8 26 LSModelImportTest and also Error The type 'LSModelImportTest.Product' already contains a definition for '_productId' D:\VS_2008_Projects\LSModelImportTest\Model1.cs 16 17 LSModelImportTest and this repeats for all properties defined for the class. Thanks, |
|
|
I'm a bit confused here -- from the previous message on this thread, I thought you were writing your entities by hand (not using the designer) and you were just looking for a way to create the database tables using the command line. In which case you don't need to bring the generated .lsmodel into your project: you just need to feed it into lsupdate.exe. The only reason to bring the .lsmodel file into your project is if you want to get rid of your handwritten entities and switch to using the LightSpeed designer. Is that the case? |
|