public IListExpression <TRequest, TEntity, TResult> Property <T>(Expression <Func <TRequest, T> > property, Action <IPropertyExpression <TRequest, T, TResult> > action = null) { var expression = new PropertyExpression <TRequest, T, TResult>(property); action?.Invoke(expression); PropertyDefinitions.Add(property.GetPropertyInfo(), expression); return(this); }
public SitecoreDataMap(Database db, string connectionString, Item importItem) : base(db, connectionString, importItem) { Item fLang = SitecoreDB.GetItem(importItem.Fields["Import From Language"].Value); ImportFromLanguage = LanguageManager.GetLanguage(fLang.Name); CheckboxField cf = importItem.Fields["Recursively Fetch Children"]; RecursivelyFetchChildren = cf.Checked; //deal with sitecore properties if any Item Props = GetItemByTemplate(importItem, PropertiesFolderID); if (Props.IsNotNull()) { ChildList c = Props.GetChildren(); if (c.Any()) { foreach (Item child in c) { //create an item to get the class / assembly name from BaseMapping bm = new BaseMapping(child); if (!string.IsNullOrEmpty(bm.HandlerAssembly)) { if (!string.IsNullOrEmpty(bm.HandlerClass)) { //create the object from the class and cast as base field to add it to field definitions IBaseProperty bp = null; try { bp = (IBaseProperty)Sitecore.Reflection.ReflectionUtil.CreateObject(bm.HandlerAssembly, bm.HandlerClass, new object[] { child }); } catch (FileNotFoundException fnfe) { Log("Error", string.Format("the property:{0} binary {1} specified could not be found", child.Name, bm.HandlerAssembly)); } if (bp != null) { PropertyDefinitions.Add(bp); } else { Log("Error", string.Format("the property: '{0}' class type {1} could not be instantiated", child.Name, bm.HandlerClass)); } } else { Log("Error", string.Format("the property: '{0}' Handler Class {1} is not defined", child.Name, bm.HandlerClass)); } } else { Log("Error", string.Format("the property: '{0}' Handler Assembly {1} is not defined", child.Name, bm.HandlerAssembly)); } } } else { Log("Warn", "there are no properties to import"); } } Item Temps = GetItemByTemplate(importItem, TemplatesFolderID); if (Temps.IsNotNull()) { ChildList c = Temps.GetChildren(); if (c.Any()) { foreach (Item child in c) { //create an item to get the class / assembly name from TemplateMapping tm = new TemplateMapping(child); if (string.IsNullOrEmpty(tm.FromWhatTemplate)) { Log("Error", string.Format("the template mapping field 'FromWhatTemplate' on '{0}' is not defined", child.Name)); break; } if (string.IsNullOrEmpty(tm.ToWhatTemplate)) { Log("Error", string.Format("the template mapping field 'ToWhatTemplate' on '{0}' is not defined", child.Name)); break; } TemplateMappingDefinitions.Add(tm.FromWhatTemplate, tm); } } } }