public static EntitySetConfiguration <TEntity> AddPluralizedEntitySet <TEntity>(this ODataModelBuilder oDataModelBuilder) where TEntity : class { string entitySetName = EnglishPluralizationService.Pluralize(typeof(TEntity).Name); return(oDataModelBuilder.EntitySet <TEntity>(entitySetName)); }
protected virtual string InterceptFromItemName(string value) { if (options.ShouldPluralizeFromItemName) { return(EnglishPluralizationService.Pluralize(value)); } return(value); }
private XmlDataOptions GetXmlDataOptions <TEntity>() { var entityName = typeof(TEntity).GetCustomAttribute <EntityNameAttribute>()?.Value ?? typeof(TEntity).Name; return(new XmlDataOptions { RootElementName = _pluralizer.Pluralize(entityName), EntityName = entityName, Path = Path.Combine(_xmlDataConfig.Value.StoragePath, $"{entityName}.xml") }); }
private string CreateExpectedStatement(string creationClause, bool hasPrimaryKey, string entityName = null) { string key = hasPrimaryKey ? "PRIMARY KEY" : "KEY"; if (entityName.IsNullOrEmpty()) { entityName = EnglishPluralizationService.Pluralize(nameof(MyMovie)); } string expectedStatementTemplate = @$ "{creationClause} {entityName} ( Id INT {key},
private string GetEntityName(Type type) { if (type == typeof(OrderDetail)) { return("\"Order Details\""); } if (type == typeof(Region)) { return("Region"); } return(pluralize.Pluralize(type.Name)); }
protected string GetEntityName <T>(IEntityCreationProperties metadata) { string entityName = metadata?.EntityName; if (string.IsNullOrEmpty(entityName)) { entityName = typeof(T).Name; } if (metadata != null && metadata.ShouldPluralizeEntityName) { entityName = EnglishPluralizationService.Pluralize(entityName); } return(entityName); }
protected MongoRepository(IClientSessionHandle session, IMongoDatabase database, IMongoModelBuilder <TEntity> builder, IPluralize pluralize) { if (database == null) { throw new ArgumentNullException(nameof(database)); } if (pluralize == null) { throw new ArgumentNullException(nameof(pluralize)); } if (builder == null) { throw new ArgumentNullException(nameof(builder)); } _session = session ?? throw new ArgumentNullException(nameof(session)); builder.CreateModel(); var collectionName = pluralize.Pluralize(typeof(TEntity).Name); lock (database) { if (!database.ListCollectionNames(new ListCollectionNamesOptions { Filter = new BsonDocument("name", collectionName) }) .Any()) { database.CreateCollection(collectionName); } } _collection = database.GetCollection <TEntity>(collectionName); builder.CreateIndex(_collection.Indexes); _queryable = new MongoDbQueryableWrapper <TEntity>(_collection); }
public async Task OnGetAsync() { var recipes = new List <Recipe>(); UserId = _userManager.GetUserId(User); var searchItems = SearchString?.Split(',').Select(x => x.Trim()).Select(x => x.ToLower()).ToList(); var robustSearchItems = new List <string>(); if (searchItems != null) { foreach (var searchItem in searchItems) { robustSearchItems.Add(_pluralizer.Singularize(searchItem)); robustSearchItems.Add(_pluralizer.Pluralize(searchItem)); } } recipes = _context.Recipe .Join(_context.Ingredient, a => a.ID, b => b.RecipeId, (a, b) => a).Distinct() .Where(x => x.UserRecordNumber.Equals(UserId)) .Select(recipe => new Recipe { ID = recipe.ID, UserRecordNumber = recipe.UserRecordNumber.ToString(), Title = recipe.Title, DateAdded = recipe.DateAdded, Instruction = recipe.Instruction, Ingredients = recipe.Ingredients .Select(ingredient => new Ingredient { ID = ingredient.ID, RecipeId = ingredient.RecipeId, Name = ingredient.Name, Measurement = ingredient.Measurement, Notes = ingredient.Notes, Quantity = ingredient.Quantity }).ToList() }).ToList(); if (!string.IsNullOrEmpty(SearchString)) { var recipesFromSearch = new List <Recipe>(); recipesFromSearch.AddRange(recipes.Where(x => robustSearchItems.Any(y => x.Title.ToLower().Contains(y)))); foreach (var recipe in recipes) { foreach (var ingredient in recipe.Ingredients) { if (robustSearchItems.Any(x => ingredient.Name.ToLower().Contains(x))) { if (!recipesFromSearch.Contains(recipe)) { recipesFromSearch.Add(recipe); break; } } } } recipes = recipesFromSearch; } Recipe = recipes; }