Closed Dhaigvip closed 4 years ago
Hello @Dhaigvip and thank you for your questions.
Here are the answers:
In the version 2.0 an Utility class "DbHelper" was provided.
Starcounter 3.0 moves away from the static database access approach in favour of dependency injection with services-like database access.
A valid database transaction is required to perform a database operation.
Here is an example of how to get a unique id of a database object and how to get a database object by its unique id:
Starcounter.Database.ITransactor transactor = services.GetRequiredService<Starcounter.Database.ITransactor>();
transactor.Transact((Starcounter.Database.IDatabaseContext db) =>
{
// Select a database object using SQL SELECT query.
Something thing = db.Sql<Something>("SELECT s FROM Something s").FirstOrDefault();
// Get unique identifier of the database object.
ulong oid = db.GetOid(thing);
// Get the same database object using its unique identifier.
Something theSameThing = db.Get<Something>(oid);
});
On our docs.starcounter.io website you can read more about database access with dependency injection.
IEntity
interface is missing. Is it moved to some other namespace?
In Starcounter 2.x the IEntity
was used to implement an on delete commit hook. Starcounter 3.0 does not yet support commit hooks.
Transient attribute is missing. I am still in the middle of migration, there could be few more issues which I haven't discovered yet. It would be very helpful if you include a brief documentation about breaking changes between ver 2.0 and ver 3.0
In Starcounter 2.x, the [Transient]
attribute was used to mark certain database type properties / fields as "non database columns".
In Starcounter 3.0 RC you can achieve the same behavior with private fields, no extra attributes required.
[Database]
public abstract class Something
{
private string transientValue;
// The transient value can be exposed with a public property:
public string TransientValue
{
get => transientValue;
set => transientValue = value;
}
}
Hi Konstantin, Thanks, It gives answer to my query, very much appreciated you response.
Regards Vipul
On Tue, Jan 28, 2020 at 10:36 AM Konstantin notifications@github.com wrote:
Hello @Dhaigvip https://github.com/Dhaigvip and thank you for your questions.
Here are the answers:
In the version 2.0 an Utility class "DbHelper" was provided.
Starcounter 3.0 moves away from the static database access approach in favour of dependency injection with services-like database access.
A valid database transaction is required to perform a database operation.
Here is an example of how to get a unique id of a database object and how to get a database object by it's unique id:
Starcounter.Database.ITransactor transactor = services.GetRequiredService
(); transactor.Transact((Starcounter.Database.IDatabaseContext db) => { // Select a database object using SQL SELECT query. Something thing = db.Sql ("SELECT s FROM Something s").FirstOrDefault(); // Get unique identifier of the database object. ulong oid = db.GetOid(thing); // Get the same database object using its unique identifier. Something theSameThing = db.Get<Something>(oid);
});
On our docs.starcounter.io https://docs.starcounter.io/dependency-injection website you read more about database access with dependency injection.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Starcounter/Home/issues/470?email_source=notifications&email_token=ALO54BKVFCBICFP5FFY6XDTQ774AZA5CNFSM4KMN2YX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKCUDJA#issuecomment-579158436, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALO54BOE57QBACJGRZIAKB3Q774AZANCNFSM4KMN2YXQ .
Closing the question as answered.
Hi, Thanks for the quick answers. We at Palma have started our migration to Starcounter 3.0. Would you please prioritize adding support for commit hooks?
Regards Vipul
@Dhaigvip it is very nice to see you migrating to Starcounter 3.
Commit hooks or equivalent feature is already on our road map, and we will prioritize it as much as possible.
Could you please clarify which commit hooks you are interested in the most? Is it pre-commit or post-commit?
Hi @miyconst, At the moment I am interested in fixing OnDelete, which is defined in IEntity.
Hi @miyconst, Meanwhile, I have another question. Now "Session" isn't available in Starcounter namespace. How to handle sessions in 3? Regards Vipul
Starcounter 3.0 integrates with Kestrel web server instead of providing a proprietary alternative.
Please read official Microsoft documentation to learn how session and app state works in ASP.NET Core - Session and app state in ASP.NET Core.
Starcounter version:
3.0.0-rc-20191212
.Issue type
Issue description
I am migrating starcounter application from Starcounter ver2.0 to Starcounter.3.0.0-rc-20191212. I see that there are some breaking changes in dot net core version of Starcounter which are not documented.
Errorlist.xlsx
The same post on stackoverflow.com - Breaking changes in migrating Starcounter 2.0 to 3.0.0-rc-20191212 [closed].