system.data.sqlite

Entity Framework 6.2 - add children with DbSet.Include() but prevent duplicate children on DbSet.AddRange()

柔情痞子 提交于 2019-12-13 03:37:24
问题 EDIT: I know how to prevent duplicates when copying entities from one DbContext to another, my question is about their children. I have two contexts: DbContextHDD and DbContextUSB and they both contain a "Math" Course . DbContextHDD also contains: a "History" Course . a Student "Simon" who attends "Math" Course . a Student "Jack" who attends "History" Course . I would like to copy all Student entities from DbContextHDD to DbContextUSB and also include any Course entities not already present

C# OutOfMemory exception when returning a small DataTable

拜拜、爱过 提交于 2019-12-13 00:19:13
问题 I have a SQLite database that has a single table with 18 million rows and 24 columns. I have written a SQL query function in C#, which I expose to Excel with ExcelDNA. This is the complete code, string constr = constr = "Data Source=" + FilePath + ";Version=3;Synchronous=OFF;temp_store=memory;cache_size=700000;count_changes=off;"; DataTable dt = new DataTable(); try { SQLiteConnection conn = new SQLiteConnection(constr); SQLiteCommand command = new SQLiteCommand(SQLStatement,conn); conn.Open(

System.data.SQLite entity framework code first programmatic providername specification

穿精又带淫゛_ 提交于 2019-12-12 12:29:20
问题 I've spent a while on this now and have only found a workaround solution that I'd rather not do... I have a context as shown below. Is there a programmatic way to specify the database to connect to via the constructor, and get it to use the System.Data.SQLite entity framework provider to connect to a SQLite database? This is working via the app.config (with a connectionstring called "Context"), but not via any programmatic way I can find of supplying it. I have tried using an entity

SQLite: Multiple Connections to one file - the one and only writable is not persisted

余生颓废 提交于 2019-12-12 02:29:12
问题 We are using the System.Data.SQLite Wrapper in Version 1.0.80. Using this to establish multiple connections to a single SQLite database will show a weird behaviour. We ensure having just one writable connection and multiple read-only connections. When the first established connection is a read-only connection (using the connection string parameter Read Only=true) the second connection (which is writable due to missing read-only parameter) does not persist changes. There are no exceptions

Pass same parameters multiple times in SQLitecommand

╄→尐↘猪︶ㄣ 提交于 2019-12-11 19:19:32
问题 I like to run below query : select lon, lat from rdf_city_poi p, rdf_location l where p.location_id = l.location_id and p.poi_id = ? union all select lon, lat from rdf_poi_address p, rdf_location l where p.location_id = l.location_id and p.poi_id = ? union all select lon, lat from xtdp_poi_address pa, xtdp_location l where pa.location_id=l.location_id and pa.poi_id= ? As you can see it's required 3 times same parameter and it's value parameter ("?") ::: value (ex. 12345) I have written below

Can I use the connection from Entity Framework or should I create a new one?

送分小仙女□ 提交于 2019-12-11 07:04:20
问题 I have a SQLite Database that I access using System.Data.SQLite. The database is read into my Entity Framework Objectcontext. However, I also need direct access to the database in certain cases. Can I / Should I use the same connection that my Entity Framework object context is using? I.e. ObjectContext.Connection ? If yes, how can I access it? Casting Entities.Connection to SQLiteConnection results in "Unable to cast object of type 'System.Data.EntityClient.EntityConnection' to type 'System

Cannot encrypt / decrypt SQLite database in .NET4

妖精的绣舞 提交于 2019-12-11 04:44:33
问题 I am running Visual Studio 2010 on a Windows 7 x64. The app I'm writing is supposed to run on all platforms (AnyCPU). I'm able to encrypt/decrypt the database file if I'm using the System.Data.SQLite.dll either x86 version (sqlite-netFx40-static-binary-bundle-Win32-2010-1.0.77.0.zip) or x64 one (sqlite-netFx40-static-binary-bundle-x64-2010-1.0.77.0.zip). I need my app to run on both platforms x86 and x64 (Any CPU project build setting). I've tried installing the ADO.NET 4.0 Provider (SQLite-1

How can I bind a c#.net DataView (WPF) to a SQLite database?

心不动则不痛 提交于 2019-12-11 01:43:58
问题 I am using the official System.Data.SQLite ADO.NET provider for my application, and I am trying to display the contents of a database in a WPF DataGrid. Currently I am able to select the data I need to display from the database, but I don't how to display that data on the datagrid. I have search on the web, read blog posts, tutorials and guides, but to no avail. I am moving an application from a PHP system (using my local server) to a desktop application to be portable across systems. My

sqlite INSERT INTO … WHERE NOT EXISTS and get the id?

孤人 提交于 2019-12-10 21:51:57
问题 is it possible to get the id even if I use INSERT INTO ... WHERE NOT EXISTS? how to modify it so it will bring me the id of the inserted record or the id of the already existed record? if possible at all! INSERT INTO Timeline (name, ts) SELECT @name, @ts WHERE NOT EXISTS (SELECT 1 FROM Timeline WHERE name=@name AND ts = @ts); i have a column called " id " with auto increment integer how I can get the value of the ID? cheers 回答1: You are guaranteeing that (name,ts) is unique, so this should do

System.Data.SQLite issue on compact Framework 3.5

允我心安 提交于 2019-12-10 18:25:43
问题 I am using sqlite in my compact framework application to log the events in system. I am also using System.Data.SQLite. The event has the time stamp to describe at what time it occurred. I am storing this Time stamp as Ticks in my table. Along with this column the table contains another 5 columns of integer/text type. Below is table schema CREATE TABLE T1 (TimeStamp INTEGER, Col2 INTEGER, Col3 INTEGER, Col4 INTEGER, Col5 INTEGER, Col6 TEXT, PRIMARY KEY(TimeStamp DESC)); I am querying for the