我正在尝试在我的应用程序中有一个名为CityObject
的对象,该对象当前以一种方式组织,其中每组整数被分类到CityObject
内部的自己的结构中,变量被访问通过目录然后变量来轻松引用它们。
以下是CityObject
类:
public class CityObject
{
public struct Harvest { public int wood, stone, coal, iron, water, food; public int all() { return wood + stone + coal + iron + water + food; } }
public Harvest harvest = new Harvest();
public struct Production { public int steel, copper, gold, electricity; public int all() { return steel+copper+gold+electricity; } }
public Production production = new Production();
public struct Invention { public int medicine, electronic, motors; public int all() { return medicine+electronic+motors; } }
public Invention invention = new Invention();
public struct Structures { public int housing, barracks, laboratory, defense; public int all() { return housing+barracks+laboratory+defense; } }
public Structures structures = new Structures();
}
但是,当使用对象作为EF6的数据模型时,它们通常是严格的:
public class Test
{
public int Id { get; set; }
public String name { get; set; }
}
在使用SQLite数据库时,我是否可以保持使用更高级的CityObject
?我创建了这个表:
CREATE TABLE `Cities`
(
`User` TEXT,
`wood` INTEGER,
`stone` INTEGER,
`coal` INTEGER,
`iron` INTEGER,
`water` INTEGER,
`food` INTEGER,
`steel` INTEGER,
`copper` INTEGER,
`gold` INTEGER,
`electricity` INTEGER,
`medicine` INTEGER,
`electronic` INTEGER,
`motors` INTEGER,
`housing` INTEGER,
`barracks` INTEGER,
`laboratory` INTEGER,
`defense` INTEGER,
PRIMARY KEY(`User`)
);
我希望有一个非常直接的方法可以将该表与该对象一起使用,但我不知道该怎么做。