Click here to Skip to main content
15,891,864 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: .net all about Pin
Richard MacCutchan12-Nov-11 0:16
mveRichard MacCutchan12-Nov-11 0:16 
QuestionEntity Framework 4.1 Pin
nv_thien11-Nov-11 3:35
nv_thien11-Nov-11 3:35 
AnswerRe: Entity Framework 4.1 Pin
Pete O'Hanlon11-Nov-11 4:26
mvePete O'Hanlon11-Nov-11 4:26 
AnswerRe: Entity Framework 4.1 Pin
Not Active11-Nov-11 5:22
mentorNot Active11-Nov-11 5:22 
QuestionRe: Entity Framework 4.1 Pin
Richard MacCutchan11-Nov-11 5:29
mveRichard MacCutchan11-Nov-11 5:29 
QuestionReset/Wipe SQL CE Database which stores EntityModel Pin
Danielku158-Nov-11 11:25
Danielku158-Nov-11 11:25 
AnswerRe: Reset/Wipe SQL CE Database which stores EntityModel Pin
Not Active8-Nov-11 11:39
mentorNot Active8-Nov-11 11:39 
GeneralRe: Reset/Wipe SQL CE Database which stores EntityModel Pin
Danielku159-Nov-11 13:07
Danielku159-Nov-11 13:07 
I solved it using those statements, thanks. I was just wondering if there was any more common method for that:

C#
private bool DeleteOldData()
{
	using (var transaction = BeginTransaction(_database))
	{
		try
		{
			string[] tables = { "NToMMappingTable", "Table1", "Table2", "Table3", "Table4" };
			bool[] alter = { false, true, true, true, true };
			for (int i = 0; i < tables.Length; i++)
			{
				string table = tables[i];
				_database.ExecuteStoreCommand(string.Format("DELETE FROM [{0}]", table));
				if (alter[i])
					_database.ExecuteStoreCommand(
						string.Format("ALTER TABLE [{0}] ALTER COLUMN Id IDENTITY (1,1)", table));
			}
			// Delete old data
			transaction.Commit();
			_database.AcceptAllChanges();
			success = true;
		}
		catch (Exception e)
		{
			transaction.Rollback();
			throw;
		}
	}
}

public static DbTransaction BeginTransaction(ObjectContext context)
{
	if (context.Connection.State != ConnectionState.Open)
	{
		context.Connection.Open();
	}
	return context.Connection.BeginTransaction();
}


SQL CE does not support truncate or dbcc, but delete and alter table will work.

Thanks.
QuestionORM framework for Access Databases Pin
cjb1102-Nov-11 23:43
cjb1102-Nov-11 23:43 
AnswerRe: ORM framework for Access Databases Pin
RobCroll3-Nov-11 11:41
RobCroll3-Nov-11 11:41 
AnswerRe: ORM framework for Access Databases Pin
tosch4-Nov-11 0:18
tosch4-Nov-11 0:18 
QuestionSending Authenticated e-mail Pin
shijuse1-Nov-11 1:11
professionalshijuse1-Nov-11 1:11 
AnswerRe: Sending Authenticated e-mail Pin
Richard MacCutchan1-Nov-11 1:59
mveRichard MacCutchan1-Nov-11 1:59 
AnswerRe: Sending Authenticated e-mail Pin
Bernhard Hiller2-Nov-11 21:52
Bernhard Hiller2-Nov-11 21:52 
AnswerRe: Sending Authenticated e-mail Pin
Simon_Whale3-Nov-11 3:40
Simon_Whale3-Nov-11 3:40 
QuestionConverting Dll to CS files Pin
satyaraju 124229-Oct-11 2:57
satyaraju 124229-Oct-11 2:57 
AnswerRe: Converting Dll to CS files Pin
Philippe Mori29-Oct-11 3:13
Philippe Mori29-Oct-11 3:13 
AnswerRe: Converting Dll to CS files Pin
R&D Ninja29-Oct-11 17:24
R&D Ninja29-Oct-11 17:24 
AnswerRe: Converting Dll to CS files Pin
Abhinav S29-Oct-11 17:31
Abhinav S29-Oct-11 17:31 
AnswerRe: Converting Dll to CS files Pin
jgegroups3-Nov-11 0:36
jgegroups3-Nov-11 0:36 
AnswerRe: Converting Dll to CS files Pin
BobJanova3-Nov-11 2:34
BobJanova3-Nov-11 2:34 
QuestionNeed to develop a tool for Load/performance testing Pin
yaswi28-Oct-11 15:26
yaswi28-Oct-11 15:26 
AnswerRe: Need to develop a tool for Load/performance testing Pin
Philippe Mori29-Oct-11 3:29
Philippe Mori29-Oct-11 3:29 
QuestionLinq query for splitting a string Pin
RowanArkison27-Oct-11 10:16
RowanArkison27-Oct-11 10:16 
AnswerMessage Removed Pin
27-Oct-11 10:25
professionalN_tro_P27-Oct-11 10:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.