SubSonic-3.0
SubSonic-3.0 copied to clipboard
Problem with Schemas while doing Update
This SubSonic Update Query:
var db = new Edumatic3DB();
var qry = db.Update<MetaDataKeyBooleans>()
.Set(x => x.Name == metaDataKeyBoolean.name)
.Set(x => x.DefaultValue == metaDataKeyBoolean.defaultValue);
if (metaDataKeyStructureId != -1)
{
qry.Set(x => x.MetaDataKeyStructureId == metaDataKeyStructureId);
}
qry.Where(x => x.MetaDataKeyBooleanId == metaDataKeyBoolean.id).Execute();
Gives me an error saying that the MetaDataKeyBooleans object is invalid... It is not in dbo schema but in MetaData schema.
I solved this in Update.cs in the Update method:
/// <summary>
/// Initializes a new instance of the <see cref="Update<T>"/> class.
/// </summary>
/// <param name="table">The table.</param>
public Update(ITable table)
{
_query = new SqlQuery(table.Provider);
_provider = table.Provider;
_query.QueryCommandType = QueryType.Update;
ITable tbl = table;
DatabaseTable dbTable = new DatabaseTable(tbl.SchemaName, tbl.Name, _provider, tbl.ClassName);
dbTable.Columns = tbl.Columns;
_query.FromTables.Add(dbTable);
}
new DatabaseTable didn't give the SchemaName as an argument.
Don't know if I can commit this fix.
I performed the same fix in my version. Line 122. Been running production app for a while with no issue.