Could not load file or assembly Oracle.DataAccess

In the IIS Manager select your server and select “Application Pools“. Select the application pool used by your Web App and click on “Advanced Settings” from the right hand menu. In the “General Section” of the advanced Settings click on the “Enable 32-bit Applications” and set it to True. This fix only applies to 64-bit … Read more

Entity Framework Code First Lazy Loading

This is wrong “virtual” keyword is used for not loading the entities unless you explicit this (using an “Include” statement) Lazy Loading means that entities will be automatically loaded when you first access collection or navigation property, and that will happen transparently, as though they were always loaded with parent object. Using “include” is loading … Read more

Multiple where conditions in EF [duplicate]

You can chain your where clauses. You just need an IQueryable datasource. var filteredData = _repository.GetAll(); //If your data source is IEnumerable, just add .AsQueryable() to make it IQueryable if(keyWordTextBox.Text!=””) filteredData=filteredData.Where(m=>m.Keyword.Contains(keyWordTextBox.Text)); if(LocationDropDown.SelectedValue!=”All”) filteredData=filteredData.Where(m=>m.Location==LocationDropDown.SelectedValue)); … etc…. Because it is IQueryable, the data is not fetched until you bind it so it only pulls the data you … Read more

Why LINQ to Entities does not recognize the method ‘System.String ToString()?

That can’t be converted to SQL. I guess, in theory, it could, but isn’t implemented. You just need to perform your projection after you have your results: var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing select m.PricingSecurityID).AsEnumerable() .Select(x => new SelectListItem{ Text = x.ToString(), Value = x.ToString() });

Entity Framework 4.1+ many-to-many relationships change tracking

Here is how to find all the changed many-to-many relationships. I’ve implemented the code as extension methods: public static class IaExtensions { public static IEnumerable<Tuple<object, object>> GetAddedRelationships( this DbContext context) { return GetRelationships(context, EntityState.Added, (e, i) => e.CurrentValues[i]); } public static IEnumerable<Tuple<object, object>> GetDeletedRelationships( this DbContext context) { return GetRelationships(context, EntityState.Deleted, (e, i) => e.OriginalValues[i]); … Read more

EF (entity framework) usage of “using” statement

I think you will find many suggesting this style of pattern. Not just me or Henk DBContext handling Yes, Ideally Using statements for DBContext subtypes Even better Unit Of Work patterns that are managed with Using, that have a context and dispose the context Just 1 of many UoW examples, this one from Tom Dykstra … Read more