SubSonic无法识别SQLite外键(SubSonic not recognizing SQLite foreign keys)
我正在使用SubSonic 3.0.0.3,我似乎无法获得ActiveRecord .tt文件来识别和生成我的SQLite数据库中的外键和关系的代码。
我认为它可以很好地生成其他所有内容,但在查看其他在线代码片段之后,看起来应该有更多生成的代码,而不仅仅是
ActiveRecord.cs
单个类和每个表的Structs.cs
。 在Structs.cs
里面,IsForeignKey
对于每一列都是false
的,甚至是我为其定义的外键。 此外,每个Foreign Keys
区域在每个生成的ActiveRecord类中都是空的。我在我的项目中使用的VS2008引用了SubSonic 3.0.0.3,System.Data.SQLite 1.0.66.0和System.Data.SQLite.Linq 2.0.38.0。 我使用SQLite Expert Personal 3.1.0.2076创建了数据库。 我做了一些虚拟表来尝试测试SubSonic如何处理一个:很多很多:许多关系。 这是我的小型数据库的DDL SQLite Expert吐出:
CREATE TABLE [Person] ( [PersonID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [PersonName] TEXT NOT NULL, [PersonAge] INT NOT NULL ); CREATE TABLE [Group] ( [GroupID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [GroupName] TEXT NOT NULL, [GroupDescription] TEXT NOT NULL ); CREATE TABLE [Dog] ( [DogID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [PersonID] INT NOT NULL CONSTRAINT [DogPersonFK] REFERENCES [Person]([PersonID]) ON DELETE CASCADE ON UPDATE CASCADE, [DogName] TEXT NOT NULL); CREATE TABLE [GroupPersons] ( [GroupID] INTEGER NOT NULL CONSTRAINT [GroupPersonToGroupFK] REFERENCES [Group]([GroupID]) ON DELETE CASCADE ON UPDATE CASCADE, [PersonID] INTEGER NOT NULL CONSTRAINT [GroupPersonToPersonFK] REFERENCES [Person]([PersonID]) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT [sqlite_autoindex_GroupPersons_1] PRIMARY KEY ([GroupID], [PersonID]));
我知道外键已启用并在数据库中工作 - SQLite Expert说他们正在使用,当我在一个地方更改数据时,比如Person的PersonID,它确实改变了Dog和GroupPersons表中的PersonID。 我已经尝试将数据库重新添加到项目中,“运行自定义工具”以使.tt文件再次执行,甚至删除它们并将其添加回来。 我可以创建一个简单的项目来执行简单的查询和插入,但是我现在尝试更改单个Person,Dog或Group的主键和x.Save(),但是System.Data.SQLite引发了异常这三个,
SQLite error near "WHERE":syntax error.
说SQLite error near "WHERE":syntax error.
在Save()。对于我接下来应该尝试做什么的任何建议?
I'm using SubSonic 3.0.0.3 and I can't seem to get the ActiveRecord .tt files to recognize and generate code for the foreign keys and relationships in my SQLite database.
I think it generates everything else just fine, but after looking at other snippets online it looks like there should be more generated code than just single classes in
ActiveRecord.cs
andStructs.cs
for each of my tables. Looking insideStructs.cs
,IsForeignKey
is alwaysfalse
for every column, even the ones I have a foreign key defined for. Additionally, eachForeign Keys
region is empty within each generated ActiveRecord class.I'm using VS2008 with references to SubSonic 3.0.0.3, System.Data.SQLite 1.0.66.0, and System.Data.SQLite.Linq 2.0.38.0 in my project. I created the database using SQLite Expert Personal 3.1.0.2076. I made some dummy tables to try to test out how SubSonic handles one:many and many:many relationships. Here's the DDL SQLite Expert spits out for my small database:
CREATE TABLE [Person] ( [PersonID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [PersonName] TEXT NOT NULL, [PersonAge] INT NOT NULL ); CREATE TABLE [Group] ( [GroupID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [GroupName] TEXT NOT NULL, [GroupDescription] TEXT NOT NULL ); CREATE TABLE [Dog] ( [DogID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [PersonID] INT NOT NULL CONSTRAINT [DogPersonFK] REFERENCES [Person]([PersonID]) ON DELETE CASCADE ON UPDATE CASCADE, [DogName] TEXT NOT NULL); CREATE TABLE [GroupPersons] ( [GroupID] INTEGER NOT NULL CONSTRAINT [GroupPersonToGroupFK] REFERENCES [Group]([GroupID]) ON DELETE CASCADE ON UPDATE CASCADE, [PersonID] INTEGER NOT NULL CONSTRAINT [GroupPersonToPersonFK] REFERENCES [Person]([PersonID]) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT [sqlite_autoindex_GroupPersons_1] PRIMARY KEY ([GroupID], [PersonID]));
I know foreign keys are enabled and work in the database - SQLite Expert says they're on and when I change data in one place, like Person's PersonID, it does indeed change that PersonID in the Dog and GroupPersons tables. I've tried re-adding the database to the project, 'running custom tool' to get the .tt files to execute again, and even deleting them and adding them back. I can get a simple project to build that perform simple querying and insertions, however I tried just now to change the primary key of a single Person, Dog, or Group and x.Save() but System.Data.SQLite threw an exception for all three, saying
SQLite error near "WHERE":syntax error.
at the Save().Any suggestions for what I should try to do next?
原文:https://stackoverflow.com/questions/3552902
最满意答案
SelectBox是泛型类,可以是任何类似于String的类。
SelectBox<T> sel=new SelectBox<T>(skin);
如果你想dropDown应该是颜色名称比T应该是字符串。
并为您的不同字符串创建数组并传入SelectBox。SelectBox is generic class, that can be anything like String.
SelectBox<T> sel=new SelectBox<T>(skin);
If you want dropDown Should be Name of Color than T should be String.
and create array for your different string and pass into SelectBox.
相关问答
更多-
似乎关于LiveWallpapers的维基已经过时了(我要检查一下)。 这就是我这样做的方式: MainActivity.java package com.zoryth.blockslw; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.badlogic.gdx.backends.android. ...
-
android中的libgdx(libgdx in android)[2023-06-14]
您是否在扩展AndroidApplication的Android类中初始化它? 它应该看起来像: public void onCreate(final Bundle savedInstanceState) { super.onCreate( savedInstanceState ); this.initialize(new Game2D, false); } 参数“false”告诉应用程序使用OpenGL ES 1.0(GL10): OpenGL ES 1.0 == GL10 OpenGL ... -
由于SelectBox引用 ,您正在寻找的方法是 public void setItems(T... newItems) 您可以使用它,例如: SelectBox.SelectBoxStyle boxStyle = new SelectBox.SelectBoxStyle(); //creating boxStyle... String[] values = new String[]{"value1", "value2", "value3", "value4"}; ...
-
android - libgdx - 如何显示选择框中的颜色列表?(android - libgdx - how can I show colors list in selectbox?)[2023-11-27]
SelectBox是泛型类,可以是任何类似于String的类。 SelectBoxsel=new SelectBox (skin); 如果你想dropDown应该是颜色名称比T应该是字符串。 并为您的不同字符串创建数组并传入SelectBox。 SelectBox is generic class, that can be anything like String. SelectBox sel=new SelectBox (skin); If you want dropDown S ... -
SelectBox使用List来显示其值。 List使用此方法转换其子项: protected String toString (T obj) { return obj.toString(); } 这不是您通常的包含和管理其子代的actor:它基本上有一个数据容器列表,将它们转换为字符串(同时允许您通过扩展类来覆盖其转换方法)。 渲染方法不期望数据容器是actor:它只是使用字体来呈现它们被转换成的文本。 您基本上必须实现自定义选择actor,可能使用ScrollPane的Table (或其他容器 ...
-
Android上的Libgdx文本(Libgdx text on Android)[2023-02-26]
根据维基 要从另一个线程将数据传递到呈现线程,我们建议使用Application.postRunnable()。 这将在调用ApplicationListener.render()之前在下一帧的渲染线程中运行Runnable中的代码。 Label是libgdx的2D场景图的一部分,因此最好与Stage一起使用。 如果你想绘制字体,你可以在Batch的帮助下绘制。 font.draw(batch,"Hello World",100,100); According to the wiki To pass da ... -
Libgdx或本地人(Libgdx or native for this)[2021-02-27]
如果您确定不打算定位其他平台,可以将代码从默认核心项目移动到Android项目中,然后在那里工作,随意调用任何API。 但是你会失去在桌面上测试的能力。 为了保持对其他平台的可移植性以及在桌面上进行测试的能力,您可以创建一个列出您要调用的所有Android API方法的界面。 将此界面的实例传递到Android项目中游戏的构造函数中,这样您的游戏就可以间接调用它们。 您的桌面项目可以使用空或系统日志记录方法传入此接口的实例。 例: public class MyGdxGame extends Applica ... -
用于android的libGDX动画(libGDX animation for android)[2024-03-04]
有一些人有例外,其中logcat说: GdxRuntimeException: Libgdx requires OpenGL ES 2.0 这是因为您的模拟器不使用您的gpu进行图形处理,最好的解决方案是使用您的手机来测试您的应用程序,但如果出于任何原因您不能使用@AngelAngel应用此解决方案: libgdx android在启动时失败 。 出于某种原因(可能是opengl没有出现故障),以下错误的解决方案也可能对您有所帮助 com.badlogic.gdx.utils.GdxRuntime ... -
Libgdx和Android NFC(Libgdx and Android NFC)[2022-05-11]
像这样把一些接口放在主项目中。 public interface NfcCommunicator { public void initialize(); public void sendData(Object data); public void setReceiveCallback(NfcReceiveCallback callback); public void checkForReceivedData(); } 和, public class NfcReceiveCa ... -
请尝试以下方法并通过dermetfan完成此youtube系列。 Java游戏开发(LibGDX) Try following and working through this youtube series by dermetfan. Java Game Development (LibGDX)