当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteAsyncConnection.InsertAsync方法代码示例

本文整理汇总了C#中SQLite.SQLiteAsyncConnection.InsertAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection.InsertAsync方法的具体用法?C# SQLiteAsyncConnection.InsertAsync怎么用?C# SQLiteAsyncConnection.InsertAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLite.SQLiteAsyncConnection的用法示例。


在下文中一共展示了SQLiteAsyncConnection.InsertAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadData

        private async void loadData()
        {
            //SQLiteAsyncConnection conn1 = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);

            
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);
            conn.DropTableAsync<SampleAppointment>();

            await conn.CreateTableAsync<SampleAppointment>();

            DateTime temp = DateTime.Now;

            DateTime start = DateTime.Parse("06/08/2013 6:00 PM");
            DateTime end = DateTime.Parse("06/09/2013 6:00 PM");

            SampleAppointment appointment1 = new SampleAppointment
            {
                Subject = "MACF - App Camp",
                AdditionalInfo = "BRTN 291, RSVP Reguired",
                StartDate = start,
                EndDate = end
            };

            conn.InsertAsync(appointment1);

            SampleAppointment appointment2 = new SampleAppointment
            {
                StartDate = DateTime.Now.AddMinutes(30),
                EndDate = DateTime.Now.AddHours(1),
                Subject = "Appointment 376",
                AdditionalInfo = "Info 3"
            };

            conn.InsertAsync(appointment2);

            start = DateTime.Parse("06/05/2013 5:00 PM");
            end = DateTime.Parse("06/05/2013 6:00 PM");
            SampleAppointment appointment3 = new SampleAppointment
            {
                StartDate = DateTime.Now.AddHours(2),
                EndDate = DateTime.Now.AddHours(3),
                Subject = "Appointment uhy4",
                AdditionalInfo = "Info 4"
            };

            conn.InsertAsync(appointment3);

            SampleAppointment appointment4 = new SampleAppointment
            {
                Subject = "Malaysian Night",
                AdditionalInfo = "STEW Common, Members Only",
                StartDate = start,
                EndDate = end
            };

            conn.InsertAsync(appointment4);

            //this.OnDataLoaded();
        }
开发者ID:KIshen90,项目名称:FreeFoodEngine,代码行数:59,代码来源:CalendarPage.xaml.cs

示例2: SetValueAsyncInternal

        private static async Task SetValueAsyncInternal(string name, string value, SQLiteAsyncConnection conn)
        {
            // if we don't have a connection, assume the system one...
            if(conn == null)
			    conn = StreetFooRuntime.GetSystemDatabase();

			// load an existing value...
			var setting = await conn.Table<SettingItem>().Where(v => v.Name == name).FirstOrDefaultAsync();
			if (setting != null)
			{
				// change and update...
				setting.Value = value;
				await conn.UpdateAsync(setting);
			}
			else
			{
				setting = new SettingItem()
				{
					Name = name,
					Value = value
				};

				// save...
				await conn.InsertAsync(setting);
			}
        }
开发者ID:jimgrant,项目名称:ProgrammingWindowsStoreApps,代码行数:26,代码来源:SettingItem.cs

示例3: btnOK_Click

        private async void btnOK_Click(object sender, RoutedEventArgs e)
        {
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true);

            Person person = new Person
            {
                DoctorName = watermarkTextBox.Text,
                Date = datepick.ValueString,
                Time = timepick.ValueString
             };

            await conn.InsertAsync(person);

            //My_Medi.ViewModels.MainViewModel veiw = new ViewModels.MainViewModel();

            //veiw.LoadData();
            DataContext = App.ViewModel;
            App.ViewModel.Items.Clear();
            App.ViewModel.LoadData();            
            

            NavigationService.GoBack();
            
            


        }
开发者ID:ZytrixSathwikE,项目名称:Windows,代码行数:27,代码来源:Add_appointment.xaml.cs

示例4: AddVisit

		public async Task<int> AddVisit(Visit visit) {
			SQLiteAsyncConnection conn = new SQLiteAsyncConnection(this.dbPath);
			if (visit.ID > 0) {
				return await conn.UpdateAsync(visit);
			}
			return await conn.InsertAsync(visit);
		}
开发者ID:jarwol,项目名称:WheredWeEat-CS,代码行数:7,代码来源:SQLiteAPI.cs

示例5: WriteMessage

        public async Task WriteMessage(string messageString)
        {
            var message = new Message {MessageString = messageString};

            var connection = new SQLiteAsyncConnection(_databasePath);

            await connection.InsertAsync(message);
        }
开发者ID:ezeh2,项目名称:ezeh2.github.io,代码行数:8,代码来源:MessageRepository.cs

示例6: Button_Click_2

 private async void Button_Click_2(object sender, RoutedEventArgs e)
 {
     SQLiteAsyncConnection conn = new SQLiteAsyncConnection(ApplicationData.Current.LocalFolder.Path + "\\people.db");
     Person person = new Person
     {
         Name = "张三",
         Work = "程序员"
     };
     await conn.InsertAsync(person);
     Person person2 = new Person
     {
         Name = "李四",
         Work = "设计师"
     };
     await conn.InsertAsync(person2);
     MessageBox.Show("插入数据成功");
 }
开发者ID:peepo3663,项目名称:WindowsPhone8,代码行数:17,代码来源:MainPage.xaml.cs

示例7: InsertOrganization

 public async static Task InsertOrganization(Organization organization)
 {
     SQLiteAsyncConnection sqlConnection = new SQLiteAsyncConnection(DbHelper.DB_PATH);
     var collectionItem = await sqlConnection.Table<Organization>().Where(x => x.Id == organization.Id).FirstOrDefaultAsync();
     if (collectionItem == null)
     {
         await sqlConnection.InsertAsync(organization);
     }
 }
开发者ID:maskaravivek,项目名称:FoodMenu,代码行数:9,代码来源:OrganizationStore.cs

示例8: AddOrUpdateCounterAsync

        public async Task AddOrUpdateCounterAsync(Counter counter)
        {
            var connection = new SQLiteAsyncConnection(_dbPath);
            if (counter.Id == 0)
                await connection.InsertAsync(counter);
            else
                await connection.InsertOrReplaceAsync(counter);

            OnCountersChanged();
        }
开发者ID:jimbobbennett,项目名称:StupendousCounter,代码行数:10,代码来源:DatabaseHelper.cs

示例9: insertProduct

        public static async void insertProduct(Product product)
        {
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(PRODUCTS_TABLE);

            await conn.CreateTableAsync<Product>();

            await conn.InsertAsync(product);


        }
开发者ID:vlddamian2,项目名称:doi,代码行数:10,代码来源:DBEngine.cs

示例10: addFavouriteStop

        // Favourites

        public static async Task<int> addFavouriteStop(OCDirection direction)
        {
            int result = 0;
            String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
            await conn.InsertAsync(direction).ContinueWith((t) =>
           {
               result = t.Result;
           });
            return result;
        }
开发者ID:jules2689,项目名称:OCTranspoWP8,代码行数:13,代码来源:OCTranspoStopsData.cs

示例11: Button_Click

        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            SQLiteAsyncConnection conn = new SQLiteAsyncConnection("institutionFinder.db");
            await conn.InsertAsync(newColleges);

            // Add to the user list
            college.Add(newColleges);

            // Refresh user list
            searchColleges.ItemsSource = null;
            searchColleges.ItemsSource = college;
        }
开发者ID:ymasilela,项目名称:SQLITE,代码行数:12,代码来源:SearchCollege.xaml.cs

示例12: createSettingsTable

 private static async void createSettingsTable()
 {
     String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
     SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
     var count = await conn.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='OCSettings'");
     if (count == 0)
     {
         await conn.CreateTableAsync<OCSettings>();
         OCSettings settings = OCSettings.newOCSettings(500);
         settings.id = 1;
         await conn.InsertAsync(settings);
     }
 }
开发者ID:jules2689,项目名称:OCTranspoWP8,代码行数:13,代码来源:OCTranspoStopsData.cs

示例13: Button_Click_2

 private async void Button_Click_2(object sender, RoutedEventArgs e)
 {
     var path = ApplicationData.Current.LocalFolder.Path + @"\Users.db";
     var db = new SQLiteAsyncConnection(path);
     var data = new User
     {
         name=txt_name.Text,
         email=txt_email.Text
     
     };
     int i = await db.InsertAsync(data);
    
 }
开发者ID:hrishikeshgoyal,项目名称:apps_development,代码行数:13,代码来源:MainPage.xaml.cs

示例14: ConnectionInit

 /// <summary>
 /// Initialise the Database connection and creates tables/default values if not existant.
 /// </summary>
 private async void ConnectionInit()
 {
     //Connection init
     var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     Database = new SQLite.SQLiteAsyncConnection(dbPath);
     //Create tables if not exists
     await Database.CreateTablesAsync(new Account().GetType(), new DatabaseRoute().GetType(), new DatabasePOI().GetType());
     await Database.ExecuteAsync("create table if not exists \"RouteBinds\"(\"RouteID\" integer,\"WaypointID\" integer);", new object[] { });
     //Set default Admin Admin password
     var result = await Database.ExecuteScalarAsync<String>("Select Gebruikersnaam From Account WHERE Gebruikersnaam = ? AND Password = ?", new object[] { "Admin", "Admin" });
     if(result == null)
         await Database.InsertAsync(new Account("Admin", "Admin"));
 }
开发者ID:Kraegon,项目名称:GTec,代码行数:16,代码来源:DatabaseConnector.cs

示例15: IncrementCounterAsync

        public async Task IncrementCounterAsync(Counter counter)
        {
            var connection = new SQLiteAsyncConnection(_dbPath);

            counter.Value++;
            await AddOrUpdateCounterAsync(counter);
            var history = new CounterIncrementHistory
            {
                CounterId = counter.Id,
                IncrementDateTimeUtc = DateTime.UtcNow
            };

            await connection.InsertAsync(history);
        }
开发者ID:jimbobbennett,项目名称:StupendousCounter,代码行数:14,代码来源:DatabaseHelper.cs


注:本文中的SQLite.SQLiteAsyncConnection.InsertAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。