support for servicestack ormlite timestamp - ormlite-servicestack

is it possible to use SqlServer Timestamp for optimistic concurency in servicestack-ormlite?
currently if I am using it ormlite is trying to update it, I guess I need an attribute to tell ormlite that this is row-version.
if something like this does note exist, I guess it should be not easy to add it, my only question is should it be done with an attribute? if yes where should i put this attribute
thanks

Related

Decimal/Date Sorting With Entity Framework Core and SQLite

Using Entity Framework Core (Code First) and SQLite, Guid is stored as binary but Decimal and Date fields are stored as text with Microsoft's provider.
I can understand they might not want the imprecision of DOUBLE for currency amounts and thus use text.
What happens if I need to sort? Is Entity Framework Core smart enough to make sorting work as expected (but slower because it needs to parse everything!), or will it sort alphabetically instead of sorting by number? I don't want it to return 100 before 2.
I'll have to do things like "give me the latest order" so what's the best approach for that? I want to make sure it's going to work.
Am I better to switch to System.Data.SQLite provider to store dates in UNIX format (this is not supported by the Microsoft's provider)? and then would I have to do the parsing back and forth myself or it could take care of it automatically?
I am still learning system.data.sqlite myself, but I am aware that you can create and assign a custom collation to your column. The collation can either be assigned to the table column, or only to a particular view or query using standard sqlite SQL syntax and the COLLATE keyword.
This is not a complete example/tutorial, but for starters visit the Microsoft.data.sqlite docs. Also see this stack overflow answer. These are just hints, but provide a consistent method to do this. Remember that sqlite is an in-process DB engine, so it should still be rather efficient and still allow working with the database in a normal fashion without having to constantly inject custom logic between queries. Once you have the custom collation defined and properly registered, it should be rather seamless with perhaps the only extra requirement to append e.g. COLLATE customDecimal to the ORDER BY clauses.
The custom collation function would convert the string value to an appropriate numeric type and return the comparison. It's very similar to the native .Net IComparer and IComparison interfaces/implementations.

Alternate to fallbackToDestructiveMigration()?

I don't want to provide a migration script while changing table schema in realm java. Also, app should not crash and all the previous data should be erased or truncated something similar to fallbackToDestructiveMigration() as room dose?
Realm provides RealmConfiguration.Builder().deleteIfMigrationNeeded()..., where deleteIfMigrationNeeded() does exactly what you are looking for.

Are stuff inside an ASP.NET .resx "static?"

In ASP.NET, can I store parameterized sql queries in .resx files and not get into trouble when I have several users logged in at the same time?
For example, i'll put my user detail query in a .resx file:
SELECT * FROM User WHERE UserId = #UserId
How will ASP.NET treat it? Like a "Session" (different users have different results) or like a "public static"/"Application" ?
resource files are typically for storing language specific strings, not for storing queries to execute, I guess you could do it, but why? It seems that there is a piece missing from your question, what is driving this requirement on your end?
EDIT: If you only have access to mysql, why not use an ORM tool like subsonic or nhibernate
I'm not intending to comment so much on whether this is a good idea or not, but basically, aren't you just storing strings? When you use a parameterized query, in ADO.NET at least, you will add the parameters before running the query.
#UserID would have to come from your code, which needs to somehow obtain the value from the logged-in user (or however your app works), so it doesn't matter how static or not the strings are.
That said, you should be using stored procedures if possible instead of this.

SubSonic 3.0 Migrations Vs. SimpleRepository Auto-Migrations: Foreign keys support?

I'm considering using SubSonic to create and access an SQLite database.
Not sure yet what flavor fits better for me though I tend to prefer the SimpleRepository approach.
Indeed I don't expect my DB to do much more than storing my objects and basic querying.
I've been through to docs but there are still a few points unclear to me or that I'd like to have confirmation for:
1/ Does "3.0 Migrations" fully support SQLite ?
2/ Using SimpleRepository, is the auto-migration feature equivalent to the 'regular' migration feature or does it support only a subset of it (apart from the incremental aspect) ?
3/ In particular, how can one specify a foreign key like it can be done with Migration.CreateForeignKey(TableColumn oneTable, TableColumn manyTable)?
I would love a [SubSonicForeignKey(Table, Column)] attribute to flag a property as such for helping relationship navigations and also indexing the column.
I suppose I'm dreaming, and the best solution I've found so far is like described in this post:
http://www.frozenmountain.com/blog/post/Automatic-Foreign-Objects-in-SubSonic3-SimpleRepository.aspx
4/ But this still can't address the missing index. So to the Subsonic Team: Any chance to see a [SubSonicIndex] attribute some day?
Thanks!

Asp.net - Trouble with updating LINQ Classes

We just created a new field in a database table, and so deleted, and re-inserted the table in the LINQ Class. The new database field appears in the LINQ Class in the diagram. However, when we're using the field, we get an error that says the table does not contain a definition for the field.
Any ideas on how we can solve this? Thanks!
UPDATE: What steps are required to update the LINQ to SQL Class? Maybe we're doing something wrong.
UPDATE 2: Picture of our problem - LINQ - http://img99.imageshack.us/img99/6033/usertable.png | Code - http://img43.imageshack.us/img43/5145/linqerror.png
Check the table def side of your mapping documents, either using properties in the designer, or by closing Studio and examining the XML. I recommend the designer.
Make sure the field name matches the field name in the database.
I've had problems with a few reserved keywords when using Linq2Entities, and I'd recommend you avoid reserved words in names (even though the [] handle them).
While this doesn't answer your question necessary, it may help to solve it - I've been a long time fan of the LINQ to SQL and Entities tools by Huagati. The re-sync aspect alone has saved me so much time, it's well worth the $50 (for the standard version) IMO.
http://www.huagati.com/dbmltools/
Hope it helps...
Edit:
In order to update the LINQ to SQL classes, you can either do it manually (bllurgh) or, you can remove them from the designer and drag-and-drop them from the Data Connections node in the Server Explorer.
I had to delete the entire LINQ Class, recreate it and re-add the tables for my problem to go away. Simply deleting a single table and re-adding it, or deleting all tables in the class and re-adding them did not work either.
I was having exactly the same issue, but I found that deleting the problematic tables in the Object Relational Designer and re-adding them (and re-adding the associations as well) solved the issue. I did not have to delete the entire DataContext, nor did I have to delete any of the tables that were still working properly. I would recommend trying this first before doing anything more drastic.

Resources