public Implementations FindImplementations(PropertyRoute route) { if (route.PropertyRouteType == PropertyRouteType.LiteEntity) { route = route.Parent; } Type type = route.RootType; if (!Tables.ContainsKey(type)) { return(Schema.Current.Settings.GetImplementations(route)); } Field field = TryFindField(Table(type), route.Members); //if (field == null) // return Implementations.ByAll; FieldReference refField = field as FieldReference; if (refField != null) { return(Implementations.By(refField.FieldType.CleanType())); } FieldImplementedBy ibField = field as FieldImplementedBy; if (ibField != null) { return(Implementations.By(ibField.ImplementationColumns.Keys.ToArray())); } FieldImplementedByAll ibaField = field as FieldImplementedByAll; if (ibaField != null) { return(Implementations.ByAll); } Implementations?implementations = CalculateExpressionImplementations(route); if (implementations != null) { return(implementations.Value); } var ss = Schema.Current.Settings; if (route.Follow(r => r.Parent) .TakeWhile(t => t.PropertyRouteType != PropertyRouteType.Root) .Any(r => ss.FieldAttribute <IgnoreAttribute>(r) != null)) { var ib = ss.FieldAttribute <ImplementedByAttribute>(route); var iba = ss.FieldAttribute <ImplementedByAllAttribute>(route); return(Implementations.TryFromAttributes(route.Type.CleanType(), route, ib, iba) ?? Implementations.By()); } throw new InvalidOperationException("Impossible to determine implementations for {0}".FormatWith(route, typeof(IEntity).Name)); }
public override Implementations?GetImplementations() { var cleanType = PropertyInfo.PropertyType.CleanType(); if (!typeof(IEntity).IsAssignableFrom(cleanType)) { return(null); } var fi = Reflector.TryFindFieldInfo(Parent.Type, PropertyInfo); if (fi != null) { return(Implementations.FromAttributes(cleanType, null, fi.GetCustomAttribute <ImplementedByAttribute>(), fi.GetCustomAttribute <ImplementedByAllAttribute>())); } if (cleanType.IsAbstract) { throw new InvalidOperationException("Impossible to determine implementations for {0}".FormatWith(PropertyInfo.PropertyName())); } return(Implementations.By(cleanType)); }
public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix) { var lites = this.ParseLiteKeys <Entity>(); if (lites.IsEmpty()) { return(Content("")); } object queryName = Finder.ResolveQueryName(webQueryName); Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll : Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray()); var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext { Url = RouteHelper.New(), ControllerContext = this.ControllerContext, Lites = lites, QueryName = queryName, Implementations = implementations, Prefix = prefix, }); if (items.IsNullOrEmpty()) { return(Content("")); } var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml())); sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>")); return(Content(sb.ToHtml().ToString())); }
public void MetaConditional() { var dic = DynamicQueryCore.QueryMetadata( from a in Database.Query <AlbumEntity>() select new { Author = a.Id > 1 ? (ArtistEntity)a.Author : (IAuthorEntity)(BandEntity)a.Author } ); DirtyMeta meta = (DirtyMeta)dic["Author"]; Assert.Equal(meta.Implementations, Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); }
public void MetaCoallesce() { var dic = DynamicQuery.QueryMetadata( from a in Database.Query <AlbumEntity>() select new { Author = (ArtistEntity)a.Author ?? (IAuthorEntity)(BandEntity)a.Author } ); DirtyMeta meta = (DirtyMeta)dic["Author"]; Assert.AreEqual(meta.Implementations, Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); }
static Implementations DefaultImplementations(Type type, object queryName) { var property = type.GetProperty("Entity", BindingFlags.Instance | BindingFlags.Public); if (property == null) { throw new InvalidOperationException("Entity property not found on query {0}".FormatWith(QueryUtils.GetKey(queryName))); } return(Implementations.By(property.PropertyType.CleanType())); }
public JsonResult GetUserQueryImplementations() { var userQuery = Lite.Parse <UserQueryEntity>(Request["userQuery"]); var entityType = userQuery.InDB(a => a.EntityType.Entity)?.ToType(); return(new JsonResult { Data = entityType == null ? new JsExtensions.JsTypeInfo[0] : Implementations.By(entityType).ToJsTypeInfos(isSearch: false, prefix: "") }); }
public JsonNetResult Autocomplete(string types, string q, int l) { Type[] typeArray = EntityBase.ParseTypes(types); if (typeArray == null) { throw new ArgumentException("ImplementedByAll not allowed in Autocomplete"); } List <Lite <Entity> > lites = AutocompleteUtils.FindLiteLike(Implementations.By(typeArray), q, l); var result = lites.Select(o => new AutocompleteResult(o)).ToList(); return(this.JsonNet(result)); }
public DashboardSelector() { DashboardPermission.ViewDashboard.Authorize(); InitializeComponent(); cpCombo.LoadData += cpCombo_LoadData; cpCombo.Implementations = Implementations.By(typeof(DashboardEntity)); cpCombo.Type = typeof(Lite <DashboardEntity>); cpCombo.LabelText = typeof(DashboardEntity).NiceName(); cpCombo.Create = Navigator.IsCreable(typeof(DashboardEntity)); cpCombo.View = Navigator.IsViewable(typeof(DashboardEntity)); cpCombo.Find = false; cpCombo.Remove = false; this.Loaded += new RoutedEventHandler(DashboardView_Loaded); }
//public static FluentInclude<T> WithQuery<T, A>(this FluentInclude<T> fi, Func<Expression<Func<T, A>>> lazyQuerySelector) <-- C# Generic argument inference not so smart as to do this public static FluentInclude <T> WithQuery <T>(this FluentInclude <T> fi, Func <Expression <Func <T, object?> > > lazyQuerySelector) where T : Entity { QueryLogic.Queries.Register(typeof(T), new DynamicQueryBucket(typeof(T), () => DynamicQueryCore.FromSelectorUntyped(lazyQuerySelector()), Implementations.By(typeof(T)))); return(fi); }
private static Implementations ParseImplementations(string types) { return(Implementations.By(types.Split(',').Select(a => TypeLogic.GetType(a.Trim())).ToArray())); }
protected override Expression VisitConstant(ConstantExpression c) { Type type = TableType(c.Value); if (type != null) { if (typeof(Entity).IsAssignableFrom(type)) { return(new MetaProjectorExpression(c.Type, new MetaExpression(type, new CleanMeta(Implementations.By(type), PropertyRoute.Root(type))))); } if (type.IsInstantiationOf(typeof(MListElement <,>))) { var parentType = type.GetGenericArguments()[0]; ISignumTable st = (ISignumTable)c.Value; TableMList rt = (TableMList)st.Table; PropertyRoute element = rt.PropertyRoute.Add("Item"); return(new MetaProjectorExpression(c.Type, new MetaMListExpression(type, new CleanMeta(Implementations.By(parentType), PropertyRoute.Root(rt.PropertyRoute.RootType)), new CleanMeta(element.TryGetImplementations(), element)))); } } return(MakeVoidMeta(c.Type)); }
public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <AlbumEntity>() .WithExpressionFrom((IAuthorEntity au) => au.Albums()) .WithQuery(() => a => new { Entity = a, a.Id, a.Name, a.Author, a.Label, a.Year }); AlbumGraph.Register(); sb.Include <NoteWithDateEntity>() .WithSave(NoteWithDateOperation.Save) .WithQuery(() => a => new { Entity = a, a.Id, a.Text, a.Target, a.CreationTime, }); sb.Include <ConfigEntity>() .WithSave(ConfigOperation.Save); MinimumExtensions.IncludeFunction(sb.Schema.Assets); sb.Include <ArtistEntity>() .WithSave(ArtistOperation.Save) .WithVirtualMList(a => a.Nominations, n => (Lite <ArtistEntity>)n.Author) .WithQuery(() => a => new { Entity = a, a.Id, a.Name, a.IsMale, a.Sex, a.Dead, a.LastAward, }); new Graph <ArtistEntity> .Execute(ArtistOperation.AssignPersonalAward) { CanExecute = a => a.LastAward != null ? "Artist already has an award" : null, Execute = (a, para) => a.LastAward = new PersonalAwardEntity() { Category = "Best Artist", Year = DateTime.Now.Year, Result = AwardResult.Won }.Execute(AwardOperation.Save) } .Register(); sb.Include <BandEntity>() .WithQuery(() => a => new { Entity = a, a.Id, a.Name, a.LastAward, }); new Graph <BandEntity> .Execute(BandOperation.Save) { CanBeNew = true, CanBeModified = true, Execute = (b, _) => { using (OperationLogic.AllowSave <ArtistEntity>()) { b.Save(); } } } .Register(); sb.Include <LabelEntity>() .WithSave(LabelOperation.Save) .WithQuery(() => a => new { Entity = a, a.Id, a.Name, }); sb.Include <FolderEntity>() .WithQuery(() => e => new { Entity = e, e.Id, e.Name }); RegisterAwards(sb); QueryLogic.Queries.Register(typeof(IAuthorEntity), () => DynamicQueryCore.Manual(async(request, description, cancellationToken) => { var one = await(from a in Database.Query <ArtistEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Artist", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }) .ToDQueryable(description) .AllQueryOperationsAsync(request, cancellationToken); var two = await(from a in Database.Query <BandEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Band", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }) .ToDQueryable(description) .AllQueryOperationsAsync(request, cancellationToken); return(one.Concat(two).OrderBy(request.Orders).TryPaginate(request.Pagination)); }) .Column(a => a.LastAward, cl => cl.Implementations = Implementations.ByAll) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((ArtistEntity a) => a.Id), PropertyRoute.Construct((BandEntity a) => a.Id)), entityImplementations: Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); Validator.PropertyValidator((NoteWithDateEntity n) => n.Text) .IsApplicableValidator <NotNullValidatorAttribute>(n => Corruption.Strict); } }
static Expression BindMember(Expression source, MemberInfo member, Type memberType) { switch (source.NodeType) { case ExpressionType.MemberInit: return(((MemberInitExpression)source).Bindings .OfType <MemberAssignment>() .SingleEx(a => ReflectionTools.MemeberEquals(a.Member, member)).Expression); case ExpressionType.New: NewExpression nex = (NewExpression)source; if (nex.Type.IsInstantiationOf(typeof(Grouping <,>)) && member.Name == "Key") { return(nex.Arguments[0]); } if (nex.Members != null) { PropertyInfo pi = (PropertyInfo)member; return(nex.Members.Zip(nex.Arguments).SingleEx(p => ReflectionTools.PropertyEquals((PropertyInfo)p.First, pi)).Second); } break; } if (source is MetaMListExpression mme) { var ga = mme.Type.GetGenericArguments(); if (member.Name == "Parent") { return(new MetaExpression(ga[0], mme.Parent)); } if (member.Name == "Element") { return(new MetaExpression(ga[1], mme.Element)); } throw new InvalidOperationException("Property {0} not found on {1}".FormatWith(member.Name, mme.Type.TypeName())); } if (typeof(ModifiableEntity).IsAssignableFrom(source.Type) || typeof(IEntity).IsAssignableFrom(source.Type)) { var pi = member as PropertyInfo ?? Reflector.TryFindPropertyInfo((FieldInfo)member); if (pi == null) { return(new MetaExpression(memberType, new DirtyMeta(null, Array.Empty <Meta>()))); } MetaExpression meta = (MetaExpression)source; if (pi.DeclaringType == typeof(MixinEntity) && pi.Name == nameof(MixinEntity.MainEntity)) { var rootType = ((CleanMeta)meta.Meta).PropertyRoutes.Single().RootType; return(new MetaExpression(rootType, new CleanMeta(Implementations.By(rootType), PropertyRoute.Root(rootType)))); } if (meta.Meta.Implementations != null) { var routes = meta.Meta.Implementations.Value.Types.Select(t => PropertyRoute.Root(t).Add(pi)).ToArray(); return(new MetaExpression(memberType, new CleanMeta(GetImplementations(routes, memberType), routes))); } if (meta.Meta is CleanMeta) { PropertyRoute[] routes = ((CleanMeta)meta.Meta).PropertyRoutes.Select(r => r.Add(pi.Name)).ToArray(); return(new MetaExpression(memberType, new CleanMeta(GetImplementations(routes, memberType), routes))); } if (typeof(Entity).IsAssignableFrom(source.Type) && !source.Type.IsAbstract) //Works for simple entities and also for interface casting { var pr = PropertyRoute.Root(source.Type).Add(pi); return(new MetaExpression(memberType, new CleanMeta(pr.TryGetImplementations(), pr))); } } if (source.Type.IsLite() && member.Name == "Entity") { MetaExpression meta = (MetaExpression)source; if (meta.Meta is CleanMeta) { PropertyRoute[] routes = ((CleanMeta)meta.Meta).PropertyRoutes.Select(pr => pr.Add("Entity")).ToArray(); return(new MetaExpression(memberType, new CleanMeta(meta.Meta.Implementations, routes))); } } return(MakeDirtyMeta(memberType, null, source)); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { if (!Schema.Current.Settings.TypeValues.ContainsKey(typeof(TimeSpan))) { sb.Settings.FieldAttributes((AlbumEntity a) => a.Songs[0].Duration).Add(new Signum.Entities.IgnoreAttribute()); sb.Settings.FieldAttributes((AlbumEntity a) => a.BonusTrack.Duration).Add(new Signum.Entities.IgnoreAttribute()); } sb.Include <AlbumEntity>() .WithExpressionFrom(dqm, (IAuthorEntity au) => Database.Query <AlbumEntity>().Where(a => a.Author == au)) .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.Name, a.Author, a.Label, a.Year }); AlbumGraph.Register(); sb.Include <NoteWithDateEntity>() .WithSave(NoteWithDateOperation.Save) .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.Text, a.Target, a.CreationTime, }); sb.Include <ConfigEntity>() .WithSave(ConfigOperation.Save); MinimumExtensions.IncludeFunction(sb.Schema.Assets); sb.Include <ArtistEntity>() .WithSave(ArtistOperation.Save) .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.Name, a.IsMale, a.Sex, a.Dead, a.LastAward, }); new Graph <ArtistEntity> .Execute(ArtistOperation.AssignPersonalAward) { Lite = true, AllowsNew = false, CanExecute = a => a.LastAward != null ? "Artist already has an award" : null, Execute = (a, para) => a.LastAward = new PersonalAwardEntity() { Category = "Best Artist", Year = DateTime.Now.Year, Result = AwardResult.Won }.Execute(AwardOperation.Save) } .Register(); sb.Include <BandEntity>() .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.Name, a.LastAward, }); new Graph <BandEntity> .Execute(BandOperation.Save) { AllowsNew = true, Lite = false, Execute = (b, _) => { using (OperationLogic.AllowSave <ArtistEntity>()) { b.Save(); } } } .Register(); sb.Include <LabelEntity>() .WithSave(LabelOperation.Save) .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.Name, }); RegisterAwards(sb, dqm); dqm.RegisterQuery(typeof(IAuthorEntity), () => DynamicQueryCore.Manual(async(request, descriptions, token) => { var one = (from a in Database.Query <ArtistEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Artist", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }) .ToDQueryable(descriptions) .AllQueryOperationsAsync(request, token); var two = (from a in Database.Query <BandEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Band", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }) .ToDQueryable(descriptions) .AllQueryOperationsAsync(request, token); return((await one).Concat(await two).OrderBy(request.Orders).TryPaginate(request.Pagination)); }) .Column(a => a.LastAward, cl => cl.Implementations = Implementations.ByAll) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((ArtistEntity a) => a.Id), PropertyRoute.Construct((BandEntity a) => a.Id)), entityImplementations: Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); Validator.PropertyValidator((NoteWithDateEntity n) => n.Text) .IsApplicableValidator <StringLengthValidatorAttribute>(n => Corruption.Strict); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(CompanyEntity)); sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(PersonEntity)); sb.Include <PersonEntity>() .WithSave(CustomerOperation.Save) .WithQuery(dqm, () => r => new { Entity = r, r.Id, r.FirstName, r.LastName, r.DateOfBirth, r.Phone, r.Fax, r.Address, }); sb.Include <CompanyEntity>() .WithSave(CustomerOperation.Save) .WithQuery(dqm, () => r => new { Entity = r, r.Id, r.CompanyName, r.ContactName, r.ContactTitle, r.Phone, r.Fax, r.Address, }); dqm.RegisterQuery(CustomerQuery.Customer, () => DynamicQueryCore.Manual(async(request, descriptions, token) => { var persons = Database.Query <PersonEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "P " + p.Id, Name = p.FirstName + " " + p.LastName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperationsAsync(request, token); var companies = Database.Query <CompanyEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "C " + p.Id, Name = p.CompanyName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperationsAsync(request, token); return((await persons).Concat(await companies) .OrderBy(request.Orders) .TryPaginate(request.Pagination)); }) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((PersonEntity comp) => comp.Id), PropertyRoute.Construct((CompanyEntity p) => p.Id)) .ColumnProperyRoutes(a => a.Name, PropertyRoute.Construct((PersonEntity comp) => comp.FirstName), PropertyRoute.Construct((PersonEntity comp) => comp.LastName), PropertyRoute.Construct((CompanyEntity p) => p.CompanyName)) .ColumnProperyRoutes(a => a.Address, PropertyRoute.Construct((PersonEntity comp) => comp.Address), PropertyRoute.Construct((PersonEntity comp) => comp.Address)) .ColumnProperyRoutes(a => a.Phone, PropertyRoute.Construct((PersonEntity comp) => comp.Phone), PropertyRoute.Construct((CompanyEntity p) => p.Phone)) .ColumnProperyRoutes(a => a.Fax, PropertyRoute.Construct((PersonEntity comp) => comp.Fax), PropertyRoute.Construct((CompanyEntity p) => p.Fax)) , entityImplementations: Implementations.By(typeof(PersonEntity), typeof(CompanyEntity))); dqm.RegisterExpression((CustomerEntity c) => c.Address).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Phone).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Fax).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); } }
public List <Lite <Entity> > Autocomplete(Type type, string subString, int count) { return(Autocomplete(Implementations.By(type), subString, count)); }
public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { QueryLogic.Queries.Register(UserADQuery.ActiveDirectoryUsers, () => DynamicQueryCore.Manual(async(request, queryDescription, cancellationToken) => { ClientCredentialProvider authProvider = GetClientCredentialProvider(); GraphServiceClient graphClient = new GraphServiceClient(authProvider); var query = graphClient.Users.Request() .Filter(request.Filters, queryDescription) .Select(request.Columns, queryDescription) .OrderBy(request.Orders, queryDescription) .Paginate(request.Pagination); query.QueryOptions.Add(new QueryOption("$count", "true")); query.Headers.Add(new HeaderOption("ConsistencyLevel", "eventual")); var result = await query.GetAsync(cancellationToken); var count = ((JsonElement)result.AdditionalData["@odata.count"]).GetInt32(); var skip = request.Pagination is Pagination.Paginate p ? (p.CurrentPage - 1) * p.ElementsPerPage : 0; return(result.Skip(skip).Select(u => new { Entity = (Lite <Entities.Entity>?)null, u.Id, u.DisplayName, u.UserPrincipalName, u.Mail, u.GivenName, u.Surname, u.JobTitle, OnPremisesExtensionAttributes = u.OnPremisesExtensionAttributes?.Let(ea => new OnPremisesExtensionAttributesModel { ExtensionAttribute1 = ea.ExtensionAttribute1, ExtensionAttribute2 = ea.ExtensionAttribute2, ExtensionAttribute3 = ea.ExtensionAttribute3, ExtensionAttribute4 = ea.ExtensionAttribute4, ExtensionAttribute5 = ea.ExtensionAttribute5, ExtensionAttribute6 = ea.ExtensionAttribute6, ExtensionAttribute7 = ea.ExtensionAttribute7, ExtensionAttribute8 = ea.ExtensionAttribute8, ExtensionAttribute9 = ea.ExtensionAttribute9, ExtensionAttribute10 = ea.ExtensionAttribute10, ExtensionAttribute11 = ea.ExtensionAttribute11, ExtensionAttribute12 = ea.ExtensionAttribute12, ExtensionAttribute13 = ea.ExtensionAttribute13, ExtensionAttribute14 = ea.ExtensionAttribute14, ExtensionAttribute15 = ea.ExtensionAttribute15, }), u.OnPremisesImmutableId, u.CompanyName, u.CreationType, u.AccountEnabled, }).ToDEnumerable(queryDescription).Select(request.Columns).WithCount(count)); }) .Column(a => a.Entity, c => c.Implementations = Implementations.By()) .ColumnDisplayName(a => a.Id, () => ActiveDirectoryMessage.Id.NiceToString()) .ColumnDisplayName(a => a.DisplayName, () => ActiveDirectoryMessage.DisplayName.NiceToString()) .ColumnDisplayName(a => a.Mail, () => ActiveDirectoryMessage.Mail.NiceToString()) .ColumnDisplayName(a => a.GivenName, () => ActiveDirectoryMessage.GivenName.NiceToString()) .ColumnDisplayName(a => a.Surname, () => ActiveDirectoryMessage.Surname.NiceToString()) .ColumnDisplayName(a => a.JobTitle, () => ActiveDirectoryMessage.JobTitle.NiceToString()) .ColumnDisplayName(a => a.OnPremisesExtensionAttributes, () => ActiveDirectoryMessage.OnPremisesExtensionAttributes.NiceToString()) .ColumnDisplayName(a => a.OnPremisesImmutableId, () => ActiveDirectoryMessage.OnPremisesImmutableId.NiceToString()) .ColumnDisplayName(a => a.CompanyName, () => ActiveDirectoryMessage.CompanyName.NiceToString()) .ColumnDisplayName(a => a.AccountEnabled, () => ActiveDirectoryMessage.AccountEnabled.NiceToString()) , Implementations.By()); } }
public override Implementations?GetImplementations() { return(Implementations.By(entityType)); }
private IEnumerable AutocompleteTextBox_AutoCompleting(string arg, CancellationToken ct) { return(Server.Return((IBaseServer s) => s.FindLiteLike(Implementations.By(typeof(ProductEntity)), arg, 5))); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(CompanyEntity)); sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(PersonEntity)); sb.Include <PersonEntity>(); sb.Include <CompanyEntity>(); dqm.RegisterQuery(typeof(PersonEntity), () => from r in Database.Query <PersonEntity>() select new { Entity = r, r.Id, r.FirstName, r.LastName, r.DateOfBirth, r.Phone, r.Fax, r.Address, }); dqm.RegisterQuery(typeof(CompanyEntity), () => from r in Database.Query <CompanyEntity>() select new { Entity = r, r.Id, r.CompanyName, r.ContactName, r.ContactTitle, r.Phone, r.Fax, r.Address, }); new Graph <CustomerEntity> .Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .Register(); new Graph <CompanyEntity> .Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .RegisterReplace(); new Graph <PersonEntity> .Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .RegisterReplace(); dqm.RegisterQuery(typeof(CustomerEntity), () => DynamicQuery.Manual((QueryRequest request, QueryDescription descriptions) => { var persons = Database.Query <PersonEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "P " + p.Id, Name = p.FirstName + " " + p.LastName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperations(request); var companies = Database.Query <CompanyEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "C " + p.Id, Name = p.CompanyName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperations(request); return(persons.Concat(companies) .OrderBy(request.Orders) .TryPaginate(request.Pagination)); }) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((PersonEntity comp) => comp.Id), PropertyRoute.Construct((CompanyEntity p) => p.Id)) .ColumnProperyRoutes(a => a.Name, PropertyRoute.Construct((PersonEntity comp) => comp.FirstName), PropertyRoute.Construct((PersonEntity comp) => comp.LastName), PropertyRoute.Construct((CompanyEntity p) => p.CompanyName)) .ColumnProperyRoutes(a => a.Address, PropertyRoute.Construct((PersonEntity comp) => comp.Address), PropertyRoute.Construct((PersonEntity comp) => comp.Address)) .ColumnProperyRoutes(a => a.Phone, PropertyRoute.Construct((PersonEntity comp) => comp.Phone), PropertyRoute.Construct((CompanyEntity p) => p.Phone)) .ColumnProperyRoutes(a => a.Fax, PropertyRoute.Construct((PersonEntity comp) => comp.Fax), PropertyRoute.Construct((CompanyEntity p) => p.Fax)) , entityImplementations: Implementations.By(typeof(PersonEntity), typeof(CompanyEntity))); dqm.RegisterExpression((CustomerEntity c) => c.Address).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Phone).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Fax).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { if (!Schema.Current.Settings.TypeValues.ContainsKey(typeof(TimeSpan))) { sb.Settings.FieldAttributes((AlbumEntity a) => a.Songs[0].Duration).Add(new Signum.Entities.IgnoreAttribute()); sb.Settings.FieldAttributes((AlbumEntity a) => a.BonusTrack.Duration).Add(new Signum.Entities.IgnoreAttribute()); } sb.Include <AlbumEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, a.Author, a.Label, a.Year }); sb.Include <NoteWithDateEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Text, a.Target, a.CreationTime, }); sb.Include <PersonalAwardEntity>(); sb.Include <AwardNominationEntity>(); sb.Include <ConfigEntity>(); MinimumExtensions.IncludeFunction(sb.Schema.Assets); sb.Include <ArtistEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, a.IsMale, a.Sex, a.Dead, a.LastAward, }); dqm.RegisterExpression((IAuthorEntity au) => Database.Query <AlbumEntity>().Where(a => a.Author == au), () => typeof(AlbumEntity).NicePluralName(), "Albums"); sb.Include <BandEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, a.LastAward, }); sb.Include <LabelEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, }); sb.Include <AmericanMusicAwardEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Year, a.Category, a.Result, }); sb.Include <GrammyAwardEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Year, a.Category, a.Result }); sb.Include <PersonalAwardEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Year, a.Category, a.Result }); sb.Include <AwardNominationEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Award, a.Author }); dqm.RegisterQuery(typeof(IAuthorEntity), () => DynamicQueryCore.Manual((request, descriptions) => { var one = (from a in Database.Query <ArtistEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Artist", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }).ToDQueryable(descriptions).AllQueryOperations(request); var two = (from a in Database.Query <BandEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Band", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }).ToDQueryable(descriptions).AllQueryOperations(request); return(one.Concat(two).OrderBy(request.Orders).TryPaginate(request.Pagination)); }) .Column(a => a.LastAward, cl => cl.Implementations = Implementations.ByAll) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((ArtistEntity a) => a.Id), PropertyRoute.Construct((BandEntity a) => a.Id)), entityImplementations: Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); Validator.PropertyValidator((NoteWithDateEntity n) => n.Text) .IsApplicableValidator <StringLengthValidatorAttribute>(n => Corruption.Strict); AlbumGraph.Register(); RegisterOperations(); } }