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, After looking to the documents, and the forums, I did find some example how to do it in C# but can't figure out how to do it in .Net I have the model in attachment. The CatalogProductEntity is already created so I want to add a CatalogProductWebsite to it. I've try so many way of doing it, that it's not really usefull that I put my code here. Normaly I think I should do something like this:
But I was not able to create the code for doing it. Thanks, Jean-Francois Normand |
|
|
Hi Jean-Francois, You will want to add your CatalogProductWebsite to the CatalogProductWebsites collection on your CatalogProductEntity instance or assign the Product property to be the CatalogProductEntity instance you are parenting it to. Both actions will ultimately achieve the same result. In terms of translating between C# and VB.NET you might find an online tool such as this: http://www.developerfusion.com/tools/convert/csharp-to-vb/ useful to help translate the syntax differences between the two languages.
|
|
|
Hi, When I try to do this, its says that the CatalogProductWebsites is read-only.
I'm very new to ORM and Lightspeed, so thanks for helping me :) Thanks, JF |
|
|
No problem :) catalogProductEntity.CatalogProductWebsites is actually a collection of CatalogProductWebsite instances as you have defined it as a Many relationship, so you will want to call .Add - e.g.
On the otherside of the relationship it is a single instance so calling
would be valid there.
|
|
|
Hi, Can't make it work. Here my code: Using uow As Magento_ModelUnitOfWork = context.CreateUnitOfWork()
End Using Crash in the model with this error: Unknown column 'catalogproductwebsite.ProductId' in 'field list' Thanks alot ! |
|
|
This error is coming from the database server so it is indicating there is something wrong with the query. This generally occurs if something is incorrectly mapped e.g. you have a column name that differs from your property name and you dont have a mapping set to point this out to LightSpeed. If you perform a database sync (right click on the model and syncronize your model with the database in either direction) are there any changes listed? If not can you also attach a copy of your model (you can limit it to the 2 entities in question) and a copy of the CREATE TABLE statement for the tables in question and I can have a look at this locally for you.
|
|
|
Hi, So when I update the model, no change has been made. I've put in attachment the model (3 tables). and followed by the create statement. Thanks alot ! :) delimiter $$ CREATE TABLE CREATE TABLE delimiter $$ CREATE TABLE |
|
|
You are using a composite key and it appears there is no mapping defined to translate the field name into the appropriate column name so can you check you have assigned the column name for ProductId (it should be product_id) as LightSpeed believes you want it called ProductId. You can do this by right clicking on the entity property and checking the Column Name in the properties.
|
|
|
Are you able to send us through a repro project containing the entities from this model and the query which triggers the problem (either a unit test or a console application we can run up)? If so then I can dig more into this as this would seem like a bug if you have the column name already set.
|
|