It works with many languages:
Language | Version | Platform |
C# VB.NET Managed C++ F# C or C++ Java | .NET 3.5 .NET 3.0 .NET 2.0 .NET CF 3.5 .NET CF 2.0 .NET 1.1 | WinXP, Vista Windows Mobile Windows CE XP embedded PocketPC, PDA Linux |
From time to time I try to add something I learn, find useful. You can view my online profile at http://amantur.brandyourself.com
Language | Version | Platform |
C# VB.NET Managed C++ F# C or C++ Java | .NET 3.5 .NET 3.0 .NET 2.0 .NET CF 3.5 .NET CF 2.0 .NET 1.1 | WinXP, Vista Windows Mobile Windows CE XP embedded PocketPC, PDA Linux |
wave | |
preview |
Thank you for signing up to give us early feedback on Google Wave. We're happy to give you access to Google Wave and are enlisting your help to improve the product. |
public static ISqlQuery ToInsertQuery(this T item, IDataProvider provider) where T: class, new() { Type type = typeof(T); ITable tbl = provider.FindOrCreateTable (); Insert query = null; if (tbl != null) { Dictionary hashed = item.ToDictionary(); query = new Insert(provider).Into (tbl); foreach (string key in hashed.Keys) { IColumn col = tbl.GetColumn(key); if ((col != null) && !(col.AutoIncrement || col.IsReadOnly)) { query.Value(col.QualifiedName, hashed[key], col.DataType); } } } return query;
if ((column != null) && !column.AutoIncrement && !column.IsReadOnly)
public static ISqlQuery ToInsertQueryHmm, the problem is already sorted out. The questioner is also using dll from some old build. I compiled, added reference and re-ran the test code. No luck. It confronted me with same error. I put break point at save statement to delve deeper. The column was never set as ReadOnly :((this T item, IDataProvider provider) where T : class, new() { Type type = typeof(T); ITable tbl = provider.FindOrCreateTable (); Insert query = null; if(tbl != null) { var hashed = item.ToDictionary(); query = new Insert(provider).Into (tbl); foreach(string key in hashed.Keys) { IColumn col = tbl.GetColumn(key); if(col != null) { if(!col.AutoIncrement && !col.IsReadOnly) query.Value(col.QualifiedName, hashed[key], col.DataType); } } } return query; }
public class TestTimeStampTable: DatabaseTable { public TestTimeStampTable(IDataProvider provider):base("TestTimeStamp",provider){ ClassName = "TestTimeStamp"; SchemaName = "dbo"; ……………… ……………… Columns.Add(new DatabaseColumn("RowVersion", this) { IsPrimaryKey = false, DataType = DbType.Binary, IsNullable = false, AutoIncrement = false, IsForeignKey = false }); }
<# foreach(var col in tbl.Columns){#> Columns.Add(new DatabaseColumn("<#=col.Name#>", this) { IsPrimaryKey = <#=col.IsPK.ToString().ToLower()#>, DataType = DbType.<#=col.DbType.ToString()#>, IsNullable = <#=col.IsNullable.ToString().ToLower()#>, AutoIncrement = <#=col.AutoIncrement.ToString().ToLower()#>, IsForeignKey = <#=col.IsForeignKey.ToString().ToLower()#> }); <# }#>
IsReadOnly = <#=col.DataType.ToLower().Equals("timestamp").ToString().ToLower() #>
Columns.Add(new DatabaseColumn("RowVersion", this) { IsPrimaryKey = false, DataType = DbType.Binary, IsNullable = false, AutoIncrement = false, IsForeignKey = false, IsReadOnly = true });
Select * From TestTimeStamp
RowID | RowDescription | RowVersion |
-------- | ------------------------- | ------------------------ |
1 | Hello world! | 0x00000000000007D1 |
2 | Hello world, Again! | 0x00000000000007D2 |
(2 row(s) affected) |