microlite-orm / microlite Goto Github PK
View Code? Open in Web Editor NEWMicroLite ORM framework
Home Page: microliteorm.wordpress.com
License: Apache License 2.0
MicroLite ORM framework
Home Page: microliteorm.wordpress.com
License: Apache License 2.0
log4net 1.2.10 now installed, but it's entry in app.config throws an exception in CreateSessionFactory.
@var configSection = ConfigurationManager.ConnectionStrings["blah"]; --> "Configuration system failed to initialize"
If I comment out the entry in app.config (and remove the logging-related code, but it's the entry that's the problem) it works as before.
FATAL - Object cannot be cast from DBNull to other types.
System.InvalidCastException: Object cannot be cast from DBNull to other types.
at System.DBNull.System.IConvertible.ToDateTime(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvid
er provider)
at MicroLite.FrameworkExtensions.PropertyInfoExtensions.SetValueT(PropertyI
nfo propertyInfo, T instance, Object value) in c:\Source\GitHub\MicroLite\MicroL
ite\FrameworkExtensions\PropertyInfoExtensions.cs:line 55
at MicroLite.Core.ObjectBuilder.BuildNewInstanceT(IDataReader reader) in c:
\Source\GitHub\MicroLite\MicroLite\Core\ObjectBuilder.cs:line 46
In the Wiki, it would be useful in the Fetch section to forward refer to the upcoming Querying section.
In the Querying section, it would be useful to remind the reader of the side-effect of not specifying all the columns.
Add IList<dynamic>Projection(SqlQuery)
to IAdvancedSession
Use dynamic so this will not be available in the .net 3.5 build.
Have 1 resources file in root namespace containing all messages.
SessionFactories are cached and should be returned if the same connection name is used
Fill in Execute and ExecuteScalar
Line 109, "this.options.ConnectionName = configSection.ProviderName;" shouldn't this be "this.options.ConnectionName = configSection.Name;"?
I am using the simplest ConsoleAppender. App.config has <level value="XXX" etc. but it always behaves as if XXX = ALL.
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="FATAL"/>
</root>
</log4net>
Means that a property would be ignored when calling Session.Update()
'Delete by Identifier' is found in .Advanced but I don't really see the justification for what is considered 'Advanced' ? (Excellent general Wiki by the way !)
Move the code for the .ForConnection().CreateSessionFactory() into a new object called FluentConfiguration, Configure.Fluently() should return a new instance of the new class.
This aligns the configuration of a connection with the way configuration of extensions is done.
When the SQL is generated to perform the insert statement for a class which uses an assigned identifier, the SQL statement should include the identifier property value and column.
I found that:
Configure
.Extensions()
.WithLog4Net()
did not show .WithLog4Net() in Intellisense, just .SetLogResolver
However:
sessionFactory = Configure
.Fluently()
.WithLog4Net()
.ForConnection("Blah")
.CreateSessionFactory();
was fine
public static readonly ILog log = LogManager.GetLogger(typeof(Program));
Configure
.Extensions()
.WithLog4Net();
Then, during sessionFactory = Configure etc., an exception is raised at
MicroLite.dll!MicroLite.Logging.LogManager.GetLog("MicroLite.Configure"): return GetLogger();
"Could not load file or assembly 'log4net' or dependency. The located assembly's manifest does not match the assembly reference"
GetLog should only be invoked if log is null ? Logging to console is operating successfully before the exception is raised.
LOG: Attempting download of (local path)\log4net.DLL
WRN: Comparing the assembly name resulted in the mismatch: Build number
This is probably to do with the way I have set up log4net, but any insight would be appreciated...
In ConnectionManager.Build(SqlQuery)
it checks that the number of arguments matches the number of parameters in the SQL string, however it doesn't check for uniques.
so "WHERE Name = @p0 IR @p0 IS NULL"
should count @p0
as a single parameter, not two.
InvalidCastException
Unable to cast object of type 'System.DBNull' to type 'System.ValueType'.
at MicroLite.FrameworkExtensions.PropertyInfoExtensions.SetValue[T](PropertyInfo propertyInfo, T instance, Object value)
at MicroLite.Core.ObjectBuilder.BuildNewInstance[T](IDataReader reader)
Integer with a default value of 30 (seconds)
If Rollback has already been called, dispose should not try and roll back again.
Move into MicroLite namespace.
Use casting to make it into an SqlQuery so we can loose the IToSqlQuery interface.
Move interfaces for fluent syntax for SqlBuilder into a MicroLite.Syntax namespace or somewhere.
InvalidCastException
Invalid cast from 'System.Int32' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.Int32.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at MicroLite.FrameworkExtensions.PropertyInfoExtensions.SetValue[T](PropertyInfo propertyInfo, T instance, Object value)
at MicroLite.Core.ObjectBuilder.BuildNewInstance[T](IDataReader reader)
15 occurrences of SA1311: Static readonly fields must start wit an upper-case letter
e.g. parameterRegex (2) in ConnectionManager.cs line 26
Others are log (5), orderByRegex, selectRegex, tableNameRegex, whereRegex, listenerFactories, listenerTypes, locker, objectInfos
When reading a record from a table, if a column which is mapped to a string property has a value of null, the property ends up with the value string.Empty
instead of null
Mainly it should be called once per query rather than within ObjectBuilder so that it doesn't have to be looked up once per instance created when we build objects for a result set.
The result object is a PagedResult which has 2 properties.
Page - This is the page number requested
Results - This is an IList of objects.
Question...
Should it have ResultsPerPage for completeness ?
MissingMethodException
No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at MicroLite.ObjectInfo.CaptureProperties()
at MicroLite.ObjectInfo..ctor(Type forType)
at MicroLite.ObjectInfo.For(Type forType)
So the following query
.Where("Name = @p0", "Fred")
.AndWhere("StatusId = @p0", CustomerStatus.Active)
.OrWhere("StatusId = @p0", CustomerStatus.Disabled)
would produce the following SQL:
WHERE (Name = @p0) AND (StatusId = @p1) OR (StatusId = @p2)
I see what you mean, but it confused me at first. Maybe the last lines could read:
would translate to the following SqlQuery clause....
"...WHERE (Name = @p0) AND (StatusId = @p1) OR (StatusId = @p2)", "Fred", CustomerStatus.Active, CustomerStatus.Disabled
Means that a property would be ignored when calling Session.Insert()
Extend the IListener interface with additional methods and make it and Listener public.
Ensure that xml comments are descriptive and include exception details for any which can be thrown.
If one accidentally maps two properties to the same column, at Insert an exception is raised: "An item with the same key has already been added".
Ensure that logging message are as meaningful as possible and use the correct logging level.
Requires #27
Load the IListener when the strategy is defined for a class when the ObjectInfo for it is generated. This will prevent us from having listeners loaded for strategies we aren't actually using.
Just an observation: if you do not wish to map a property to a column, omit the 'Column' attribute.
If a transaction is not used, the connection is opened, the command executed and the command closed.
If a transaction is used, the call to BeginTransaction opens the connection, the commands are executed but the connection is not closed. This should happen upon commit or rollback.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.