C# 使用sqlite net windows phone 8.1在中间表中插入外部数据
我花了很长时间尝试在一个表中插入信息,该表具有在WindowsPhone8.1中创建的多对多关系。因为我可以这样做,以便信息自动插入中间表?我正在使用sqlite net处理表之间的关系,我的实体就是它们C# 使用sqlite net windows phone 8.1在中间表中插入外部数据,c#,windows-phone-8.1,many-to-many,insert-update,sqlite-net-extensions,C#,Windows Phone 8.1,Many To Many,Insert Update,Sqlite Net Extensions,我花了很长时间尝试在一个表中插入信息,该表具有在WindowsPhone8.1中创建的多对多关系。因为我可以这样做,以便信息自动插入中间表?我正在使用sqlite net处理表之间的关系,我的实体就是它们 [Table("Compra")] public class Compra { [PrimaryKey, AutoIncrement] //[ForeignKey(typeof(Detalle))] public int Id_Compra { get; set; }
[Table("Compra")]
public class Compra
{
[PrimaryKey, AutoIncrement]
//[ForeignKey(typeof(Detalle))]
public int Id_Compra { get; set; }
public DateTime Fecha { get; set; }
[ManyToMany(typeof(Detalle), CascadeOperations = CascadeOperation.All)]
List<Producto> Productos { get; set; }
}
[Table("Producto")]
public class Producto
{
[PrimaryKey, AutoIncrement]
//[ForeignKey(typeof(Detalle))]
public int Id_Producto { get; set; }
public string Nombre { get; set; }
public bool Comprado { get; set; }
[ManyToMany(typeof(Detalle), CascadeOperations = CascadeOperation.All )]
List<Compra> Compras { get; set; }
}
[Table("Detalle")]
public class Detalle
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[ForeignKey(typeof(Compra))]
public int Id_Compra { get; set; }
[ForeignKey(typeof(Producto))]
public int Id_Producto { get; set; }
}
是一个通俗易懂的版本,对于InsertWhithChildren,我可以自动将其插入中间表,但无法在应用程序中使用。如果有人在帮助我自己,我会非常感激,因为我已经尝试了两天,但我还没有在互联网上看到任何东西
我应该使用哪种类型的sqlite,我应该使用哪种类型的CONCONTOR sqlite和path
我需要在插入产品后将其自动插入表详细信息中谢谢您向我推荐翻译为什么不能在应用程序中使用
InsertWhithChildren
方法?谢谢您向我推荐翻译为什么不能在应用程序中使用InsertWhithChildren
方法?
private async void addProducto()
{
Producto prod = new Producto();
prod.Nombre = tbNuevoProducto.Text;
prod.Comprado = false;
SQLiteAsyncConnection conn = new SQLiteAsyncConnection("CarroCompra.db");
conn.InsertAsync(prod);
}