ef-code-first,full-text-search,iqueryable,createqueryRelated issues-Collection of common programming errors


  • Ladislav Mrnka
    entity-framework caching asp.net-mvc-3 ef-code-first entity-framework-4.1
    We are using EF code first with the App Fabric cache on Windows Azure (although, I think the question is really more generic since we are using it as an ASP.net caching provider). Is there an easy way to enable caching of DBset objects? Our db is small and not updated very frequently, so ideally we could cache the entire database in memory, and use some ttl expiry to refresh object sets. Any advise from someone with experience caching using EF code first would be great.

  • Sami
    asp.net-mvc ef-code-first
    public class dbC : DbContext {public dbC() : base(“mydb”) { }public DbSet<Attribute> attributes { get; set; }public DbSet<Category> categories { get; set; }public DbSet<Data_Type> data_Types { get; set; }public DbSet<DbField> dbFields { get; set; }public DbSet<Item> items { get; set; }public DbSet<ItemAttribute> itemAttributes { get; set; }public DbSet<Member> members { get; set; } }The database created is fine all the way exceptpublic DbSet<Data_Type

  • Mr Ignorant
    entity-framework ef-code-first sql-view
    In an attempt to write some clean model class libraries, I am using EF5 Code First. Using EntityTypeConfiguration various properties are mapped to columns of 2 VIEWS hosted on a SQL Server 2005 server instance. CAUTION: I know there is some bad table column naming going on, but I’ll have to cope with this as it is an existing database. Please forgive me.After doing the plumbing, I can query client accounts… var context = new Data.EntityContext(); public IQueryable<ClientAccount> GetClien

  • nik_boyz
    wcf asp.net-mvc-4 ef-code-first entity-framework-5
    I am using mvc4 as my web application which inherits a WCF service i have an Entity framework and used Code first for database Now, Entity layer is inherited to both MVC as well as to WCF but Data Access layer is only inherited to the WCF, Now when ever i call the WCF method from my controller the method is called nicely and the method works fine into the WCF and returns the expected result but when it returns result to the MVC application it throws an exception of “The underlying connection was

  • Anton Putov
    c# entity-framework ef-code-first dbcontext objectstatemanager
    While I iterating through ObjectStateEntries I expected [t] variable name will be MY_ENTITYforeach (ObjectStateEntry entry incontext.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted)){Type t = entry.Entity.GetType();…}but real I haveSystem.Data.Entity.DynamicProxies.MY_ENTITY_vgfg7s7wyd7c7vgvgv…..How can I determine can I cast current entry to MY_ENTITY type?

  • Aaron Anodide
    c# entity-framework ef-code-first
    I’m hoping for a quick bit of advice just to tell me weather I should suspect (a) I’ve done something wrong or (b) I am trying to do something that is unsupported.I generated the code for an DbContext with tables from QuickBooks. It has many tables that I’ll never use but I figured it wouldn’t hurt.Everything was going fine until I tried to call SaveChanges() after a single insert on the Customer table. My test case succeeded but he runtime was between 1 and 2 minutes.Then I removed all but th

  • Dragonseer
    ef-code-first code-first code-first-migrations
    So I’ve managed to get Code First running and it works great. Since I am still developing the application the structure of the Database isn’t finalize and so I need to implement migrations. I followed the Official Blog Post and got that Update-Database command working. However, this only updates the SQLExpress version of the database. The production version of the database is on Azure and I specify the connection string at run time so the Update-Database command doesn’t work on that. So my final

  • user1974729
    entity-framework ef-code-first many-to-many hashtable edf
    Problem: Manytomany relationship will not work anymore with EFCodeFirstProvider or with EDF > 4.3 and Asp.net > 4.0..It currently fails at line:RelatedEnd entityCollection = (RelatedEnd)Column.EntityTypeProperty.GetValue(e.Entity, null);Due to which i have to rewrite that code and in my new codevar hashset_prop = Column.EntityTypeProperty.GetValue(entity);i have this line of code which returns me a Hashtable<Type_only_known_at_runtime>) but i cant seem to find a way of casting it. Btw can

  • cetmrw791346
    entity-framework ef-code-first dbset
    I have a question regarding EntityFramework and accessing a list of domain type objects in my database. I’m using the Code First approach with an interface utilizing a base context class that inherits from the interface and was wondering, would having constructors like these would throw any runtime errors?Interface:IDbSet<IEnumerable<Entity>> Entities { get; }Context:DbSet<IEnumerable<Entity>> Entities { get; }Code that accesses context:_context.Entities.Add(entityList);A

  • Tommy
    entity-framework-4.1 ef-code-first
    I get the exception ‘The entity type [TYPE] is not part of the model for the current context.’ when trying to run my application. My best guess so far is that it doesn’t recognize my type as a type that it has mapped. This could very well be since it is a type loaded at runtime. This type comes from a different assembly.How does EF: CF find all it’s entities to map, and how can I make it find my types ?

  • mamesaye
    ruby-on-rails-3 full-text-search thinking-sphinx
    rake ts:rebuild execute without error, but i can’t get the index page to show i have this error: sphinxql: syntax error, unexpected AND, expecting CONST_INT (or 3 other tokens) near ‘AND `broadcast_date` BETWEEN 0 AND 0 AND `sphinx_deleted` = 0 LIMIT 0, 20; SHOW META’ controller @segments = Segment.search params[:name], :with => { :person_id => params[:person_ids] ,:broadcast_date => dbDateFrom.to_i..dbDateTo.to_i}, :page => params[:page], :per_page => 20 model class Seg

  • SLC
    full-text-search sql-server-2012
    Consider this:select * from cats where contains(catname, ‘”Furry Pudding”‘)It will match entries that contain “Furry Pudding” exactly as it’s written.Next, consider this:select * from cats where contains(catname, ‘”A B C”‘)This should match any cat that is called A B C. It doesn’t do any partial matching, and I am confident that it shouldn’t.Now consider this:select * from cats where contains(catname, ‘”A B C Furry Pudding”‘)You’d expect that to only match a cat thats name is “A B C Furry Puddin

  • OMG Ponies
    sql sql-server tsql full-text-search
    I have an Indexed View with two columns, a primary key char and a field for full-text indexing varchar(300). I need to search from a MS Great Plains database, so I created the view to populate a field with concatenated values from my primary table IV00101.CREATE VIEW SearchablePartContent WITH SCHEMABINDING AS SELECT ITEMNMBR, rtrim(ITEMNMBR)+’ ‘+rtrim(ITMSHNAM)+’ ‘+rtrim(ITMGEDSC)as SearchableContent FROM dbo.IV00101 GO — create the index on the view to be used as full text key index CREATE U

  • bluefeet
    sql full-text-search sql-server-2012
    SELECT occurrence, display_term FROM sys.dm_fts_parser (‘”ROBIX 156 DM”‘, 1033, null, 0)does not return expected results (display_term):robix 156 nn156 dmbutrobix 156 dm nn156dmWhat is ‘DM’, why its resulting in unexpected result from word breaker, and how could one avoid it ?

  • Rob
    full-text-search sql-server-2008-r2
    If I perform the following fulltext query:SELECT c.CategoryId As ID,c.Title,KEY_TBL.RANK AS [Rank]FROM dbo.Category AS cINNER JOIN FREETEXTTABLE(dbo.Category, Title, ‘back lower pain’) AS KEY_TBL ON c.CategoryId = KEY_TBL.[KEY]WHERE c.IsActive = 1ORDER BY KEY_TBL.RANK DESCAnd I have the following two entries in the Category TableID | Title | Rank ———————– 12 | Lower Body | 34 11 | Back Pain | 34I would have thought that given “Back Pain” matches two of the three words it w

  • user2696962
    mysql full-text-search
    Not sure what’s going on. I run indexer –all –rotate When it finishes mysql hangs and not accepting new connections. from my observation as soon as indexer finishes, all update,insert,delete queries goes into query end state*mysql tables are not corrupt*i’m using Percona mysql 5.6.12-56*table in Innodb type*tried to install sphinx from source and rpm, also tried Sphinx 2.1.1 and Sphinx 2.0.8indexer –all –rotate Sphinx 2.1.1-beta (rel21-r3701) Copyright (c) 2001-2013, Andrew Aksyonoff Copyri

  • kertal
    performance postgresql full-text-search
    Postgres Full Text Search performance seems to depend on the dictionary you use, here’s an example my table contains 60000 entriesdefault german dictionary (only stopwords, i think)SELECT title FROM sitesearch s, to_tsquery(‘german’,’holz’) query WHERE query @@ searchtext LIMIT 10QUERY PLANLimit (cost=247.14..282.99 rows=10 width=21) (actual time=1.286..1.534 rows=10 loops=1)-> Nested Loop (cost=247.14..1358.57 rows=310 width=21) (actual time=1.278..1.512 rows=10 loops=1)-> Function Sc

  • john
    mysql full-text-search full-text-indexing
    When i try the following query:select co_id, Match(co_title,co_description,co_text) AGAINST (‘word’) from (select * from content limit 100)cothe result is: #1191 -Can’t find FULLTEXT index matching the column listFULLTEXT indexes are set correctly :when i try :select co_id, Match(co_title,co_description,co_text) AGAINST (‘word’) from contentit works fine.why the first query is not working?

  • Horst Walter
    java jar full-text-search
    I am looking for a tool where I can search several jar, war, … files for a certain class and method (even better Signature).So far I have found tools such as JavaClassFinder where I can search for java files and classes. What I would need is to search for methods / signatures as well… I am looking for an existing solution, I do not want to write my own tool.Example: MyMethod should find all MyMethod methodsAny ideas, suggestions?

  • Sparafusile
    sqlite full-text-search prepared-statement
    I’m using the SQLite C interface to write an application. Since I like security, I’m using prepared statements to query the database. In one such query, I’m selecting rows from a virtual database using the MATCH keyword for full-text-searching. Here’s an example:SELECT * FROM Emails WHERE ( Subject LIKE ?001 OR ?001 IS NULL )AND ( Author LIKE ?002 OR ?002 IS NULL )AND ( Body MATCH ?003 OR ?003 IS NULL )This allows the user to enter any terms (Subject, Author, or Body) individually or in any comb

  • Daniel Hilgarth
    c# linq entity-framework casting iqueryable
    We are trying to cast an instance of IQueryable<EntityObject> to an IQueryable<SpecificEntityObject>, the SpecificEntityObject type is only known at runtime.We have tried using the code below, which does not compile because The type or namespace ‘objType’ does not exist.var t = query.ElementType; Type objType = typeof(IQueryable<>).MakeGenericType(t); var typed = query.Cast<IEnumerable<objType>>();var grouped = typed.GroupByMany(groupBy.Select(grp => grp.Expressi

  • Joao Leme
    c# linq dynamics-crm-2011 automapper iqueryable
    Why am I getting: The method ‘Where’ cannot follow the method ‘Select’ or is notsupported. Try writing the query in terms of supported methods or callthe ‘AsEnumerable’ or ‘ToList’ method before calling unsupportedmethods….when using the WHERE clause, like when calling:XrmServiceContext.CreateQuery<Contact>().Project().To<Person>().Where(p => p.FirstName == “John”).First();?This works:XrmServiceContext.CreateQuery<Contact>().Project().To<Person>().First();Also this w

  • Tim Skauge
    c# linq-to-sql iqueryable
    Bumped into a strange situation here. Trying to extract cars from a sql database within a certain range of a position (lat/long) and return an IQueryable to do additional logic on the resultset afterwards.public IQueryable<Car> QueryAllCarsByDistance(float latitude, float longitude, int distance) {var cars = from car in QueryAllCars()join i in sqlContext.QueryContactsByDistance(latitude, longitude, distance)on car.ContactId equals i.Idorderby i.Distanceselect car;return cars; }QueryContact

  • abatishchev
    c# linq linq-to-sql ienumerable iqueryable
    what is the difference between returning iqueryable vs ienumerable.IQueryable<Customer> custs = from c in db.Customers where c.City == “<City>” select c;IEnumerable<Customer> custs = from c in db.Customers where c.City == “<City>” select c;Will both be deferred execution? When should one be preferred over the other?

  • RemotecUk
    linq-to-sql datacontext iqueryable
    Ive got the following code which I hacked together from website examples. It works nicely but I dont really understand how it works…public static Func<EuvaTransientDataContext, string, string, int, IQueryable<SecurityAudit>>MatchedIPAddressesAuditRecords =CompiledQuery.Compile((EuvaTransientDataContext db, string username, string ipAddress, int withinHours) =>(from sa in db.SecurityAuditswhere sa.IPAddress == ipAddress &&sa.Username != username &&sa.AuditDateTime

  • TravisWhidden
    c# .net linq linq-to-sql iqueryable
    I have a paging API that returns rows a user requests, but only so many at one time, not the entire collection. The API works as designed, but I do have to calculate the total number of records that are available (for proper page calculations). Within the API, I use Linq2Sql and I work a lot with the IQueryable before i finally make my requests. When I go to get the count, I call something like: totalRecordCount = queryable.Count(); The resulting SQL is interesting none the less, but it

  • peplamb
    c# silverlight datetime date iqueryable
    I am in a situation where i need to convert fields with DateTime to a Date (DateTime (2011-01-01 00:00:00 ) to Date ( 2011-01-01 just a string with no time )) before i assign the source to the DataGrid ( without using Binding/Converters ) the collection is an IQueryable but not sure how to do it.Let me repeat I want the collection to be manipulated even before its assigned to DataGrid Sourcecan someone help me? Thanks

  • YuriyP
    c# linq-to-sql expression expression-trees iqueryable
    I want to create my custom expression for IQueryable. Sample extension method:public static IQueryable<T> GetByIntTest<T>(this IQueryable<T> qSource, Expression<Func<T, int?>> field, int? value) {if (value == null)return qSource;ConstantExpression constantExpression = Expression.Constant(value, typeof(int?));BinaryExpression binaryExpression = Expression.Equal(field.Body, constantExpression);var predicate = Expression.Lambda<Func<T, bool>>(binaryExpressi

  • Joshua Frank
    .net clr iqueryable devart
    I asked the question this way because I can imagine that there’s a potentially easy but Devart specific solution, but maybe also a very general solution for any similar situation.I’m using Devart LINQ To Oracle, and generally you create a class like ItemX in the lqml file at design time and specify what table is behind it. Then, at run time, you use a Table(Of ItemX) to query the database. So far so good.Now I’ve got a situation where I have two identical tables, ItemX and ItemY, and I need to

  • John Saunders
    c# reflection iqueryable
    I have an IList of Type Entity.I have a string representing the Type of a class derived from Entity.I need to cast my IList to IQueryable of the Type derived from Entity using the string.Sadly, the assembly for Entity and derived classes is not the executing assembly.

  • Boris
    ef-code-first full-text-search iqueryable createquery
    I am using .NET 4.5 and EF 5 with Code First approach and now I need to implement Full Text Search. I have already read a lot about it and so far my conclusions are:Stored procedures nor Table Value Functions can not be mapped with Code First. Still I can call them using dynamic sqldbContext.Database.SqlQuery<Movie>(Sql, parameters)But this returns IEnumerable and I want IQueryable so that I can do more filtering before fetching the data from db server. I know I can send those parameters t

Web site is in building