Evaluating Linq to Sql - have a few questions

Evaluating Linq to Sql - have a few questions

Postby ashlar64 » Tue 27 Dec 2011 16:55

Hello,

The company I am working for will be evaluating some ORM tools in the next few weeks. I have a few questions about your product.

1) If we bought the Professional edition would the Entity Developer be able to be used with the Entity Framework? (Does the professional edition contain the professional edition of the Entity Designer?)

2) I downloaded the trial version of LinqConnect and I don't see how I can use the Entity Designer to modify the edmx file?
ashlar64
 
Posts: 75
Joined: Thu 04 May 2006 18:56

Postby StanislavK » Tue 27 Dec 2011 17:55

LinqConnect Professional includes the version of Entity Developer that supports LinqConnect models only (though can be used with different DBMSs).

If you want to work with both LinqConnect and Entity Framework models, you can select one of the following options:
- if you are going to work with SQL Server databases only, you can purchase LinqConnect Standard and Entity Developer for Entity Framework;
- if you want to work with some other database, e.g., Oracle, you can use the Professional edition of the corresponding data provider (e.g., dotConnect for Oracle).

Feel free to contact us if anything is unclear.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby ashlar64 » Wed 28 Dec 2011 20:29

Hello,

Thanks for the prompt response. I do have one other question. Is there a way to convert the Entity Framework to a LinqConnect files? So basically the entities stay the same and the complex classes also get converted over as well?
ashlar64
 
Posts: 75
Joined: Thu 04 May 2006 18:56

Postby StanislavK » Thu 29 Dec 2011 14:01

We don't plan to implement such functionality in near future. However, you can support this suggestion at our UserVoice:
http://devart.uservoice.com/forums/38671-entity-developer/suggestions/453985-model-migration
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby ashlar64 » Thu 29 Dec 2011 21:36

Hello I have a few more questions.

1) Is there a way to easily remove all rows of data using the conext?
Something like: myContext.Orders.RemoveAllRows()?

2) If multiple people were to install a app that uses LinqConnect and they wanted to have their own unique database names is there someway to do this in code? I thought changing the database name in the Connection object might be the way. But that didn't work in my test.

3) In the scenario in 2....if they wanted to pick what database they wanted to use (MySQL or MS SQL) could that be done in code?
ashlar64
 
Posts: 75
Joined: Thu 04 May 2006 18:56

Postby StanislavK » Fri 30 Dec 2011 16:57

Concerning your questions:

1) You can use the DeleteAllOnSubmit method to delete multiple rows from the table:
Code: Select all
myContext.Orders.DeleteAllOnSubmit(myContext.Orders);
myContext.SubmitChanges();

However, this approach will actually result in a single select command and multiple delete commands (one per Order). The reason is that LinqConnect tracks the entity objects and thus should know when a particular entity is deleted.

If you want to clear a table faster, you can use the ExecuteCommand method instead:
Code: Select all
myContext.ExecuteCommand("delete from \"Orders\"");

2) Generally, it should be sufficient to specify another database in the connection string. However, this supposes that the database name is not stored in the model mapping. To ensure that this is so, ensure that you clear the 'Preserve schema name in storage' check box in the model settings when creating the model (this option is enabled by default).

3) Using the same model with different DBMSs needs different mapping sources. Attribute mapping does not provide such possibility, thus it is necessary to use the file mapping. To implement the scenario you described, it is necessary to create two mapping files (one per DBMS), and switch between them in your application.

Feel free to contact us if anything is unclear.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby ashlar64 » Thu 26 Apr 2012 20:20

Hello,

On number 2 if the lqml file has already been created where can I uncheck the 'Preserve schema name in storage' checkbox?


On #3...Could I possible see some sample code on picking either MySQL or SQLServer in code and then creating a new database that a user selects? Lets say the name is stored in: string newDatabaseName;
ashlar64
 
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Evaluating Linq to Sql - have a few questions

Postby MariiaI » Fri 27 Apr 2012 12:52

On number 2 if the lqml file has already been created where can I uncheck the 'Preserve schema name in storage' checkbox?

The 'Preserve schema name in storage' option is located on the 'General tab of the 'Model Settings' dialog box. To open this dialog box, you can, e.g., double-click the diagram canvas. But if the model has already been created, it will not affect the existing entities. To remove schema name from the existing mapping, you should recreate your model with unchecked 'Preserve schema name in storage' checkbox.

On #3...Could I possible see some sample code on picking either MySQL or SQLServer in code and then creating a new database that a user selects? Lets say the name is stored in: string newDatabaseName;

To bind the DataContext with the necessary database use the code:
Code: Select all
System.Data.Linq.Mapping.MappingSource mappingSource = Devart.Data.Linq.Mapping.XmlMappingSource.FromUrl(mappingfile);
YourDataContext context = new YourDataContext(connectionString, mappingSource);

where 'mappingfile' - the full path to the mapping file (e.g. "C:\\...\\MySQL_mapping.xml" or "C:\\...\\SQLServer_mapping.xml")
For more information about using XML mapping, see http://www.devart.com/linqconnect/docs/POCO.html

To create a new database you can use:
Code: Select all
YourDataContext dc = new YourDataContext("Host = newDatabaseName; User Id = root; password = root; Port =3306;");
dc.CreateDatabase(false,true);

For more information see:
http://www.devart.com/linqconnect/docs/DDL.html
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Evaluating Linq to Sql - have a few questions

Postby ashlar64 » Fri 27 Apr 2012 13:43

The 'Preserve schema name in storage' option is located on the 'General tab of the 'Model Settings' dialog box. To open this dialog box, you can, e.g., double-click the diagram canvas. But if the model has already been created, it will not affect the existing entities. To remove schema name from the existing mapping, you should recreate your model with unchecked 'Preserve schema name in storage' checkbox.


I need to recreate it from scratch? There is no other way? Could I perhaps copy and paste it to a blank canvas somehow? My project has over 50 tables / enums /tons of associations.....it would take a very long time to recreate it.
ashlar64
 
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Evaluating Linq to Sql - have a few questions

Postby MariiaI » Sat 28 Apr 2012 10:09

You can try to manually change it. Do the following:
- open YourDataContext.lqml file in a text editor;
- remove all the names of the schema in it (e.g. you can use the automatic replacement and replace Table Name="SCHEMANAME. with Table Name=");
- save changes;
- re-generate the code and xml mapping file for your model.

Please notify us if this helps.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)