Subsonic generate table without primary key - subsonic

I need to generate a table without primary key. Its absolutely neccessary that the table dosen't have primary key. Please help.

It is absolutely necessary for the SubSonic that table contains primary key:)
The following is quoted from the SubSonic docs on conventions:
Primary Keys
If you want to use SubSonic to access your table, you need to have a Primary Key defined for your table. This is good practice in every case and we need it to do certain things with your table. If you don't have a Primary Key defined, your class won't be generated.
If you don't believe us, or if you think this is a silly convention - SubSonic isn't for you.

Is there any reason you cannot use something like sequences?
class Something {
private static final SEQUENCE seq = getDBsequence()
#id
private final long id = seq.newNumber();
private final String whateverData;
}
EDIT:The way I wrote this was kinda dumb because once you reboot the app. you'll get duplicate keys.. You should use a sequence provided by the DB. Sorry about that.

as Adam pointed out this isn't possible. To be honest I can't think of a situation (outside OLAP) where you can't have a PK. Or perhaps you're stuck in a legacy situation - I can dig that.
What you can do to get around it is, as you pointed out, use our querier tools and then you can send the results ToList<>. Updates should work the same way - not sure about inserts though.

Related

Why does a cursor need to be sequential in pagination

I am building a cursor-based public API and read in various places that the pagination cursor should be sequential.
I use a UUID as PK and was thinking of returning the UUID PK as cursor. As a client can define filter parameters and sort-keys, I think that a UUID as cursor should be sufficient.
Are there more aspects that I am missing?
Appreciate any help
Edit: Maybe my confusion comes from a clients ability to specify sort-keys

Is there a way to create a composite primary key on a NetSuite custom record?

Is there a way to create a composite primary key on a NetSuite custom record?
I know that is possible to simulate the behavior on an user event script, but I'm looking for the best practice approach here. Maybe a way to define it using SuiteBuilder.
I also know I could trick the "externalid" field to achieve the same results, but is not the real purpose of this field. The concatenation would be a problem too.
Thanks in advance!
The NetSuite team contacted me, it turns out it is not possible to define a composite key on SuiteBuilder.
Anyway, the result can be achieved in other ways, like merging all the values in one big string, or creating an user event script to validate the fields before save.

Foreign keys not recognised

when generating an activerecord.cs from mysql using subsonic, some foreign keys are overlooked by the template. it acknowledges the table and columns, just not the relations.
i have checked all the basic things like made sure its the correct db, flushed tables, deleted classes etc.
the db is created using a dump. when i generate from this version everything works correctly. i then add some tables, which relate to existing ones. when i generate again, the new relations are missed by subsonic. the new tables have the same foreign key as existing tables.
ANY ideas will help me at this stage
thanks
solved it. although my connection string was correct(used for table generation), the following line was incorrect(used for foreign key generation) in Settings.ttinclude:
const string DatabaseName = "db";

Change connection on the fly

I have a SQL server with 50 databases. Each one has the exact same schema.
I used the awesome Subsonic 2.2 create the DAL based on one of them.
I need to loop though a list of database names and connect to each one and perform an update one at a time.
If there a way to alter how subsonic uses the connection string. I believe I would need to store the connection string in memory that way it can keep changing.
Is this possible?
I tried doing a
ConfigurationManager.ConnectionStrings["theConnStrName"].ConnectionString = updated-connection-string-here;
.. but that did not work
thanks!
Subsonic was designed primarily for one database only.
I've done multiple databases a couple of ways. I had posted a complete sample for creating providers on the fly in the old forums for subsonic. Those posts are gone now. What you can try is set up one provider in the config file (yourProviderName) with a dummy connection string just to initialize subsonic, then set the actual connection string as needed in your code. This only works with one database at a time but I think this is what you needed. If you want to use multiple databases at the same time, and involves more code and some changes to the subsonic 2.x core.
DataProvider provider = DataService.GetInstance(yourProviderName);
foreach(string connString in connectionStrings)
{
provider.DefaultConnectionString = connString;
DataService.Provider = provider;
// ... do stuff
}
I don't think it's easy to fix without creating a SubSonic provider for each database.
Instead I would put the SubSonic-source as a project in the solution and debug my way to the best and most clean place to extend the code wwith some sort of connnection string dictionary list and functionality to set the one you want at a given time.

SubSonic PrimaryKey not autoincrement

Does current version of SubSonic support PrimaryKey (Int) which is not Autoincrement?
How?
PS: If I don't use SimpleRepository() I can save new record with assigned Id so more or less I can go on, thz.
Without knowing exactly what you mean, I can tell you this much: SubSonic ActiveRecord does support such keys, you just need to remember to set them manually when creating new records.

Resources