Hello all,
I am going to enter a new project for IBM. And I showed my manager how does Subsonic works. He was delighted. But ... I don't know does Subsonic works with IBM - Informix database ?
does anybody knows ?
many thanks in advance
Contents |
Found a bug
I found a bug, subsonic 3.
MsSQL doesn't return ID from identity column, because column is "id", but generated property is "Id".
My quick fix is below - just to get it working, I am sure real fix should try to find property name out of column. (file SubSonicRepository.cs).
/// <summary>
/// Adds a T item to the db
/// </summary>
public object Add(T item, IDataProvider provider)
{
var query = item.ToInsertQuery(provider).GetCommand();
object result = null;
if(query != null)
{
if (provider.Client == DataClient.SqlClient)
{
//add in SCOPE_INDENTITY so we can pull back the ID
query.CommandSql += "; SELECT SCOPE_IDENTITY() as new_id";
}
/** add "using" keywords to dispose IDataReader rdr object after its get out of the scope **/
using (var rdr = provider.ExecuteReader(query))
{
if (rdr.Read())
result = rdr[0];
// repopulate primary key column with newly generated ID
if (result != null && result != DBNull.Value)
{
try
{
var tbl = provider.FindOrCreateTable(typeof(T));
var prop = item.GetType().GetProperty(tbl.PrimaryKey.Name);
var settable = result.ChangeTypeTo(prop.PropertyType);
prop.SetValue(item, settable, null);
}
catch (Exception x)
{
var tbl = provider.FindOrCreateTable(typeof(T));
var prop = item.GetType().GetProperty((""+tbl.PrimaryKey.Name[0]).ToUpper()+tbl.PrimaryKey.Name.Substring(1));
var settable = result.ChangeTypeTo(prop.PropertyType);
prop.SetValue(item, settable, null);
//swallow it - I don't like this per se but this is a convenience and we
//don't want to throw the whole thing just because we can't auto-set the value
}
}
}
}
return result;
}
SubSonic works with EffiProz Database
Hello, Does SubSonic works with EffiProz Database?
Optimistic Locking / Concurrency
Here's a possible solution that will provide optimistic locking using SubSonic 3.0 ActiveRecord:
http://sites.google.com/site/subsonicoptimistic/home
Found a bug Subsonic miscalculates the number of parameters in an IN clause
subsonic 3
When execute this query db.Select.From<CualificacionHistorico>().Where(CualificacionHistoricoTable.idUsuarioColumn).IsEqualTo(idUsuario).And(CualificacionHistoricoTable.cualificadoColumn).IsEqualTo(0).And(CualificacionHistoricoTable.idSubprocedimientoColumn).In(db.SelectColumns(ArticuloProcedimientoTable.idSubprocedimientoColumn).From<ArticuloProcedimiento>().Where<ArticuloProcedimiento>(x=> x.idArticulo == idArticulo)).GetCommand().CommandSql;
Subsonic return this SELECT [dbo].[CualificacionHistorico].[id], [dbo].[CualificacionHistorico].[idUsuario], [dbo].[CualificacionHistorico].[idSupervisor], [dbo].[CualificacionHistorico].[idTarea1], [dbo].[CualificacionHistorico].[idTarea2], [dbo].[CualificacionHistorico].[idSubprocedimiento], [dbo].[CualificacionHistorico].[cualificado], [dbo].[CualificacionHistorico].[eliminado], [dbo].[CualificacionHistorico].[fechaCreacion], [dbo].[CualificacionHistorico].[fechaModificacion], [dbo].[CualificacionHistorico].[guid]
FROM [dbo].[CualificacionHistorico] WHERE [dbo].[CualificacionHistorico].[idUsuario] = @0 AND [dbo].[CualificacionHistorico].[cualificado] = @1 AND [dbo].[CualificacionHistorico].[idSubprocedimiento] IN (SELECT [dbo].[ArticuloProcedimiento].[idSubprocedimiento] FROM [dbo].[ArticuloProcedimiento] WHERE [dbo].[ArticuloProcedimiento].[idArticulo] = @0)
As we can see the last select param is the same that the first select
What happen any ideas???
Generating code for all Tables in the information schema. Not for SPecific Database
Hi All,
Can anyone help me?
I am using Subsonic3.0. When I right click on the Active.tt and click "Run Custom Tool", it is generating code for all the tables in schema. I dont want that. I want to generate code for a particular databse.
My web.config code is below.
<configSections> <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/> </configSections>
<connectionStrings>
<add name="TestConn" providerName="MySql.Data.MySqlClient" connectionString="server=localhost; Database=usersample; user id=root; pwd=root;"/> </connectionStrings> <SubSonicService defaultProvider="TestConn" enableTrace="false" templateDirectory=""> <providers> <clear/> <add name="TestConn" type="SubSonic.MySqlDataProvider, SubSonic" connectionStringName="TestConn" generatedNamespace="Subsonic3sample" includeTableList="\buserinfo\b,\brolemaster\b"/> </providers> </SubSonicService>
I am using MySql database. changed all the TT files as per the requirement. Please help me.
Intro to SubSonic / no stranger to ORM
I am evaluating a couple of ORMs for use in our application.
Real briefly, I've gone to the effort of working up a "Model" of various objects which come to an integration point, Call it "ModelIntegrationObject" which connects 2-3 key layers for our application. These are all Xml serializable in and of themselves. No problem.
Now I come to the point I am ready to save this data out in some way, shape or form. Talking to the guys in the office, historically, our model files have been stored in the file system, organized different ways, and so forth. That's been historically.
I come at this with some experience with ORM, namely NHibernate and Fluent NH (flamers subside, please...) So I know with NH and FNH these are known quantities. For what we need to do in our application, however, I'm not sure this carries too much overhead for what we want to do.
In C# .NET vernacular, I am envisioning a "simple" save record to consist of an ID (of course), a Type (or Type FullName), Xml which can be deserialized, and some additional record details which mean something more to our application.
After walking through a couple of the screencasts (nice touch, BTW, SubSonic authors!), it seems as though what SubSonic can do for us gives us enough flexibility and makes the whole ORM process fairly seamless with the rest of the application.
Any thoughts along these lines?
Best regards,
Michael