本文整理汇总了C#中SQLite.SQLiteConnection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# SQLite.SQLiteConnection.Insert方法的具体用法?C# SQLite.SQLiteConnection.Insert怎么用?C# SQLite.SQLiteConnection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLite.SQLiteConnection.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connection
public static SQLite.SQLiteConnection Connection()
{
var conn = new SQLite.SQLiteConnection(DBPath);
if (!Initialized)
{
conn.CreateTable<Car.Car>();
conn.CreateTable<Fillup.Fillup>();
conn.CreateTable<Maintenance.Maintenance>();
conn.CreateTable<Reminder.Reminder>();
var cars = conn.Table<Car.Car>();
if (cars.Count() == 0)
{
Car.Car car = new Car.Car();
conn.Insert(car);
}
var firstCar = cars.First();
if (cars.Where(vehicle => vehicle.ID == Settings.CurrentCarID).Count() == 0)
Settings.CurrentCarID = firstCar.ID;
Initialized = true;
}
return conn;
}
示例2: Insert
public void Insert(Locale model)
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
db.Insert(model);
}
}
示例3: AddAlbum
public bool AddAlbum(AlbumViewModel model)
{
try
{
using (var db = new SQLite.SQLiteConnection(app.DBPath))
{
int success = db.Insert(new Album()
{
CollectionId = model.CollectionId,
Title = model.Title,
Artist = model.Artist,
LastFmId = model.LastFmId,
MusicBrainzId = model.MusicBrainzId,
DateAdded = DateTime.Now,
Void = false
});
if (success != 0)
return true;
}
return false;
}
catch
{
return false;
}
}
示例4: AddPet
public int AddPet(Pet _pet)
{
//returns new ID
int success;
using (var db = new SQLite.SQLiteConnection(Constants.DbPath))
{
success = db.Insert(new Pet()
{
PetStageId = _pet.PetStageId,
FavoriteGameObjectId = _pet.FavoriteGameObjectId,
DislikeGameObjectId = _pet.DislikeGameObjectId,
Name = _pet.Name,
Health = _pet.Health,
Hygene = _pet.Hygene,
Hunger = _pet.Hunger,
Energy = _pet.Energy,
Discipline = _pet.Discipline,
Mood = _pet.Mood,
Gender = _pet.Gender,
Age = _pet.Age,
Sleeping = _pet.Sleeping,
Current = _pet.Current,
BirthDate = _pet.BirthDate,
LastUpdated = _pet.LastUpdated,
Dead = false
});
}
return success;
}
示例5: Insert
private void Insert(Source model)
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
db.Insert(model);
}
}
示例6: butSaveClick
private void butSaveClick(object sender,EventArgs e)
{
TextView txtprinter =FindViewById<TextView> (Resource.Id.txtad_printer);
TextView txtprefix =FindViewById<TextView> (Resource.Id.txtad_prefix);
TextView txttitle =FindViewById<TextView> (Resource.Id.txtad_title);
pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
AdPara apra = new AdPara ();
apra.Prefix = txtprefix.Text.ToUpper();
apra.PrinterName = txtprinter.Text.ToUpper();
using (var db = new SQLite.SQLiteConnection(pathToDatabase))
{
var list = db.Table<AdPara> ().ToList<AdPara> ();
if (list.Count == 0) {
db.Insert (apra);
} else {
apra = list [0];
apra.Prefix = txtprefix.Text.ToUpper();
apra.PrinterName = txtprinter.Text.ToUpper();
apra.PaperSize = spinner.SelectedItem.ToString ();
apra.ReceiptTitle =txttitle.Text.ToUpper();
db.Update (apra);
}
}
base.OnBackPressed();
}
示例7: addMeterBox
public void addMeterBox(string meterBoxNumber, double current)
{
string result = string.Empty;
using (var db = new SQLite.SQLiteConnection(app.DBPath))
try
{
db.CreateTable<MeterBox>();
int success1 = db.Insert(new MeterBox()
{
ID = 0,
meterBoxNumber = meterBoxNumber,
currentUnits = current
});
var existing = db.Query<MeterBox>("select * from MeterBox").First();
if (existing == null)
{
int success = db.Insert(new MeterBox()
{
ID = 0,
meterBoxNumber = meterBoxNumber,
currentUnits = current
});
}
else if(existing != null)
{
existing.meterBoxNumber = meterBoxNumber;
existing.currentUnits = current;
db.RunInTransaction(() =>
{
db.Update(existing);
});
}
}
catch (Exception e)
{
}
//return "Success";
}
示例8: InsertUserLikes
public void InsertUserLikes(string recipeName, string memberName)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
var query = db.Insert(new Likes()
{
likesId = 0,
memName = memberName,
recipeName = recipeName
});
}
}
示例9: addInstitution
public void addInstitution(string name)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
var insert = db.Insert(new Institution()
{
Id = 0,
insitution = name
});
}
}
示例10: setLogIn
private void setLogIn(string pword, string userName,string id)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
int success = db.Insert(new tblLogIn()
{
ID = id,
Username = userName,
Password = pword,
});
}
}
示例11: memberDetails
public void memberDetails(string _name, string _surname, string _email, string _password)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
var query = db.Insert(new Member()
{
memId = 0,
name = _name,
surname = _surname,
email = _email,
password = _password
});
}
}
示例12: savePowerballGeneratedNumbers
public void savePowerballGeneratedNumbers(int first, int second, int third, int fourth, int fifth)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
var query = db.Insert(new PowerBallSaved()
{
Id = 0,
num1 = first,
num2 = second,
num3 = third,
num4 = fourth,
num5 = fifth
});
}
}
示例13: InsertPerson
public void InsertPerson()
{
if (!databaseCreated)
{
if(File.Exists(GetDatabasePath ()))
File.Delete (GetDatabasePath ());
CreateTable ();
databaseCreated = true;
}
var person = new Person { FirstName = "John", LastName = "Doe", TimeStamp = DateTime.Now.Ticks.ToString()};
using (var db = new SQLite.SQLiteConnection(GetDatabasePath() ))
{
db.Insert(person);
}
}
示例14: setUserSavedNumbers
public void setUserSavedNumbers(int a, int b, int c, int d, int e, int f)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
var query = db.Insert(new LottoSaved()
{
Id = 0,
num1 = a,
num2 = b,
num3 = c,
num4 = d,
num5 = e,
num6 = f
});
}
}
示例15: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
// Initialize the database if necessary
using (var db = new SQLite.SQLiteConnection(DBPath))
{
// Create the tables if they don't exist
db.CreateTable<Day>();
db.CreateTable<Intake>();
Day day = new Day();
day.Date = DateTime.Today;
db.Insert(day);
}
CurrentDay = DayViewModel.GetDayByDate(DateTime.Today);
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}