I have a Linq to SQL data model that uses single table inheritance.
I created a new ASP.net Dynamic Data web site with all table scaffolding enabled, but I can't see any of the derived classes in my data model being scaffolded.
Is this by design?
Table Inheritance is possible with (unreleased) ASP.NET 4.0 using LINQ to SQL. The Dynamic Data Samples / Futures download-able here have an Inheritance.dbml file that the team created specifically to demonstrate this.
Also see the Walkthrough, which applies to Entity Framework.
Related
I just started learning about asp.net mvc. My previous expierence is in python django. I was wondering when I make classes in the models file, it will automatically create those tables for me? Sorry I am a real beginner.
No, It just maps your input data and enables controllers to manipulate data and send to view. In order to fill data into database you should use LINQ to SQL and data entity framework.
I'm creating a lightweight database to rent movies.
I really like LINQ, so want to stick to that. My forms need validation so that is a requirement (ComponentModel.DataAnnotations).
Is there a model tool/template/thingy that combines them all, giving me the opportunity to create classes, generate them to the database (like the ADO.NET Entity Data Model), giving me LINQ (like LINQ to SQL Classes) and form validation (letting me implement ComponentModel.DataAnnotations)
Simply use Entity Framework - it supports all you need. Check this ScottGu's article for more info.
I have an asp.net web forms application that uses linq 2 sql. A lot of the controls are databound to linq datasource controls.
I want to clean up this application so I can easily use html5's offline functionality.
I thought I should probably move my linq 2 sql statements from code behind to classes and then call to the class. Not sure?
What I would like to do, is have a clean separation and since MS is no longer promoting linq 2 sql, I would like to move to linq 2 entities.
Eventually, a while from now, I would like to convert this app into mvc, but one step at a time.
Would it be better to just make separate data classes for each form or just create database first linq to entity classes?
Thanks,
Sheri
I would recommend reviewing the Repository Pattern suggestions here. I've been using the Repository Pattern with LINQ-to-SQL and ASP.NET MVC since 2009, and it has been very good for me for managing my data interactions, maintaining separation of concerns, and, especially, testing.
I'm hoping to generate my server-side and client-side validation (ish) using meta data on our entity classes.
I've been reading up on creating validators to use the meta data from data annotations.
However recently I've also been reading up about dynamic data.
Is my understanding corret in that the prescribed route to use data annoatations within web forms is to use asp.net dynamic data? As the custom validator tutorials seem a little old.
However, we are not using data binding as we are using the repository pattern with entity framework - does this mean we cannot use dynamic data?
The validation annotation derives from the System.ComponentModel.DataAnnotations namespace. You can use the Dynamic Data one for ASP.NET web forms, or, write your own.
Recently I am using LINQ. But when facing an interview I am unable to explain:
What is LINQ?
Moreover, is DataSet deprecated due to the introduction of LINQ?
From an interview point of view, how should I answer those questions?
LINQ is a set of extensions to the .NET framework that enables language-integrated queries. This basically means that we can use the same type of syntax to query any set of data - whether it be a SQL database, Active Directory, or XML file - we can use the same syntax to execute queries.
The mechanism that LINQ uses to communicate with the different datasources is through providers - you can write your own provider if you wish, but the default providers are LINQ-to-Objects, LINQ-to-SQL and LINQ-to-XML. So again - LINQ allows you to use the same syntax for retrieving data from a SQL database, XML file or in-memory objects.
LINQ does not replace DataSets - in fact, you can use LINQ in conjunction with datasets. The only reason why there is a debate of DataSets vs LINQ is due to LINQ-to-SQL being an ORM. This means that we now have a choice in terms of built-in technologies for communicating with the database - previously datasets would be the default built-in option, now you can also opt for LINQ-to-SQL.
Nice introduction to LINQ Just pick few most important sequences from there for your interview question. As for the second question DataSet's are not deprecated, LINQ is just adding a different way you can work with your data.
In addition to what #RaYell said you should have asked your interviewer if they were talking about LINQ or LINQ to SQL when asking if the DataSet was deprecated.
Entity Framework replaces LINQ to SQL, using an OOD approach, shielding it from the database with a mapping layer. This layer uses xml and csql to enable it to pass the data to a variety of databases, without the overhead of sql. The objects dont expose any tables, and neither would you expect it, as the objective is to abstract to enable mapping. This is clearly at odds with the dataset approach. I guess if you considered "Entity Framework to Dataset", or "Entity Framework to XML" in the same vein as LINQ, and to enable loading of these objects shielded by mapping, then you can see the value of each of these technologies. Such transformation atm seem to be via LINQ to XML, or LINQ to DATASET, and then pushing into Entity Framework. I would add that the DataSet allows for accessing tables, rows, columns dynamically and I am not sure the Entity FrameWork has such capability, it must know the data framework, hence they are complementary technologies.