Insert an entity with a nested property

Mar 25, 2015 at 10:18 AM
Edited Mar 25, 2015 at 10:19 AM
Hi all,

I stand to congratulate you for this excellent project. I have just a question, how to insert easily an entity containing a nested property.
public class Entity {
   public string Property {get; set; }
   public NestedEntity {get; set; }

public class NestedEntity {
    public string NestedProperty {get; set; }
My insert method is :
   public int Insert<T>(T entity) where T : EntityWithID
            return context.Insert<T>(typeof(T).Name, entity)
            .AutoMap(x => x.ID)
I have the following error message :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Entity (`NestedEntity`....
Have you got an idea or i dream on an inexistant fonctionnality ?

Best regards,

Mar 25, 2015 at 12:04 PM
Meanwhile I created an extension method :
 public static class FluentDataExtension
        public static IInsertBuilder<T1> AutoMapNestedProperty<T1, T2>(this IInsertBuilder<T1> builder, T2 entity, string prefix = "")
                p => { builder.Column(string.Concat(string.IsNullOrEmpty(prefix) ? typeof(T2).Name : prefix, "_", p.Name), p.GetValue(entity)); }
            return builder;
I'm a beginner (less than 1yr of c# dev xp) so tell me if it is not correct :-)