Workshop on ASP .Net MVC with Angular 4
seen from China
seen from China
seen from China
seen from United Kingdom
seen from United States
seen from United States

seen from China
seen from United Kingdom
seen from United States
seen from United States
seen from China
seen from Morocco

seen from United Kingdom
seen from China
seen from China
seen from United States
seen from China
seen from United States

seen from United States
seen from United States
Workshop on ASP .Net MVC with Angular 4
Export to word using MVC 4
In previous article I had told you how to export data into excel, in this article I will tell you…
View Post
Using Linq to filter your entity model
It is all perfectly fine to have a model but useless to you unless you can filter out only the information you want to send back to your page. Below I have created basic query:
/// <summary> /// Populates the query stem. /// </summary> /// <remarks>It was written to select out a new lightweight entity because it complains that it cannot create /// a new instance of Business class. Specifically, it gives the following error: /// The entity or complex type ‘CarnotaurusModel.Business’ cannot be constructed in a LINQ to Entities query /// So we create dynamic lightweight instance of Business. Let’s say BusinessLW. /// We then stuff it in a generic list and update our view to reflect this.</remarks> public void PopulateQueryStem() { Int32 entityTypeStringID = (int)this.searchType; this.query = (from b in model // equivalent of where clause filter on the type of business entity where b.Entity_type_string_id == entityTypeStringID select new BusinessLW { ID = b.Business_id, Title = b.Trading_name, ShortTitle = b.Search_name, Address = b.Address.Description, Postcode = b.Address.Postcode, Phone = b.Phone, // equivalent of select clause filter on trading businesses IsTrading = b.Is_trading == 1, // equivalent of select clause filter on haunted business addresses IsHaunted = b.Address.Address_extra.Any(e => e.Is_haunted == true) }); }
Please note that it uses both filtration and selection logic. These are very different in techniques. Importantly, here we want to treat the data that we selected from query, after the where clause filtration has been applied. So we had better not confuse the two kinds of logic. In the first case, filtration uses the kind of filters we would expect in the where clause if we were writing Sql. In the second case, we notice the application of selection logic when we come to build up a lightweight business entity. This is the sql equivalent of performing functions on our selected columns.
Entity Framework
If ever asked what I like most about EF4 then I would reply that it pickups up foreign keys on my database schemas. I do have a few dislikes but these are either from an architectual point of view (which has more to do with ORM itself than EF) or that when entity mappings are created, they are not visually arranged in the design view in any intelligent way.
Asp.net dynamic data entities web applications
The Asp.net dynamic data entities web application compounds several layers into one. I know that Object Relational Mapping (ORM) is supposedly the future but when layers are not exposed, it can cause serious optimisation issues as well as making testing almost impossible. This is the case with both the ADO.NET Entity Framework (EF) model and the LINQ to SQL model. These are the only out of the box model providers availabe to Asp.net dynamic data entities web application. These do not work well, if at all with Microsoft Access.
However, when there is little time to architect a proper solution, Microsoft are ingenious when it comes to dirty ways to write applications. The dynamic data entities web is one such technology to add to their bow. You might be prepared to architect a Sql Server database roughly because you anticipate having to make changes to it later. If you want a quick know around website that you want to rip out later when you have more time Asp.net dynamic data entities web applications are for you? EF goes as far as foreign keys to definite relationships. If so then follow these set up instructions, which appear a little out of date and see what happens.