首页 \ 问答 \ SubSonic无法识别SQLite外键(SubSonic not recognizing SQLite foreign keys)

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 and Structs.cs for each of my tables. Looking inside Structs.cs, IsForeignKey is always false for every column, even the ones I have a foreign key defined for. Additionally, each Foreign 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
更新时间:2024-04-28 08:04

最满意答案

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. ...
  • 您是否在扩展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"}; ...
  • SelectBox是泛型类,可以是任何类似于String的类。 SelectBox sel=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 (或其他容器 ...
  • 根据维基 要从另一个线程将数据传递到呈现线程,我们建议使用Application.postRunnable()。 这将在调用ApplicationListener.render()之前在下一帧的渲染线程中运行Runnable中的代码。 Label是libgdx的2D场景图的一部分,因此最好与Stage一起使用。 如果你想绘制字体,你可以在Batch的帮助下绘制。 font.draw(batch,"Hello World",100,100); According to the wiki To pass da ...
  • 如果您确定不打算定位其他平台,可以将代码从默认核心项目移动到Android项目中,然后在那里工作,随意调用任何API。 但是你会失去在桌面上测试的能力。 为了保持对其他平台的可移植性以及在桌面上进行测试的能力,您可以创建一个列出您要调用的所有Android API方法的界面。 将此界面的实例传递到Android项目中游戏的构造函数中,这样您的游戏就可以间接调用它们。 您的桌面项目可以使用空或系统日志记录方法传入此接口的实例。 例: public class MyGdxGame extends Applica ...
  • 有一些人有例外,其中logcat说: GdxRuntimeException: Libgdx requires OpenGL ES 2.0 这是因为您的模拟器不使用您的gpu进行图形处理,最好的解决方案是使用您的手机来测试您的应用程序,但如果出于任何原因您不能使用@AngelAngel应用此解决方案: libgdx android在启动时失败 。 出于某种原因(可能是opengl没有出现故障),以下错误的解决方案也可能对您有所帮助 com.badlogic.gdx.utils.GdxRuntime ...
  • 像这样把一些接口放在主项目中。 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)

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)