Exemple #1
0
        public static string BuildSelectColumns(this IClassMapper classMap, ISqlDialect sqlDialect)
        {
            var columns = classMap.Properties
                          .Where(p => !p.Ignored)
                          .Select(p => classMap.GetColumnName(p, sqlDialect, true));

            return(columns.AppendStrings());
        }
Exemple #2
0
        public static string GetColumnName(this IClassMapper classMapper, ISqlDialect sqlDialect, string propertyName)
        {
            var propertyMap = classMapper.GetPropertyMapByName(propertyName);

            if (propertyMap == null)
            {
                throw new NullReferenceException($"{propertyName} was not found for {classMapper.EntityType}");
            }

            return(classMapper.GetColumnName(propertyMap, sqlDialect, false));
        }
        private string GetUpdateParameterSql(IClassMapper classMapper, IProjectionSet projectionSet, IDictionary <string, object> parameters)
        {
            var propertyMap = classMapper.GetJoinedMapByName(projectionSet.PropertyName);

            if (propertyMap.Ignored || propertyMap.IsReadOnly)
            {
                throw new InvalidOperationException($"Update is not allowed for ignored or readonly property [{propertyMap.Name}]");
            }

            var paramName = $"{Configuration.Dialect.ParameterPrefix}{propertyMap.Name}";

            parameters.Add(paramName, projectionSet.Value);

            return($"{classMapper.GetColumnName(propertyMap,Configuration.Dialect,false)} = {paramName}");
        }