This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Are there plans to support views in the future? Deleting and updating are not impoortant to me, but I have a database where data is very normalized, and for reporting/ viewing purposes a view would be a lot easier / faster. Or do you have another way that I can retrieve data that is spread over many tables in a large DB effectivly?
Anthony
|
|
|
Hi Anthony, Views work at the moment. Let me know if you have any problems. Cheers, Andrew. |
|
|
Just to clarify... views work in the LightSpeed runtime. We don't currently support dragging views onto the designer (though of course you can still manually create models that correspond to views). |
|
|
That's great news :) I cant find any documentation anywhere on how I use a view. Can you point me in the right direction pls? If I use the designer to create a definition of the view, how do I use that definition and couple it to a view? thx Anthony |
|
|
Hi Anthony, Sorry, as Ivan points out I wasn't clear. We do support views - just not though the designer. It's pretty easy to create an LS model without the designer, especially if you copy an existing one. Let me know if you have any issues. Cheers, Andrew. |
|
|
To further clarify, views are supported through the designer if you use the Toolbox to create entity models. Hope this helps, Andrew. |
|
|
Ok, Supposing I use the following code to retrieve data from my view, and I create an entity model in the designer, how do I get the data from the DataReader into the entity model, Do I have to fill the model myself, or is there a Lightspeed method I can call?
System.Data.IDbCommand command = _unitOfWork.Context.DataProviderObjectFactory.CreateCommand();
Anthony
|
|
|
The LightSpeed runtime doesn't differentiate between tables and views. It just generates SQL, and SQL doesn't care whether it's querying a table or a view, so neither does LightSpeed. So provided your view conforms to the usual LightSpeed conventions (naming conventions, ID column), you don't have to do anything to make your scenario work, other than defining an entity that matches the schema of your view. You don't have to go via an IDataReader: you can just use Find directly. For example, if you have a view called Widgets, and you have an Entity called Widget whose fields correspond to the columns of Widgets, you can just write: myUnitOfWork.Find<Widget>(); LightSpeed doesn't care that Widgets is a view rather than a table. Even if the view or its columns have unconventional names, you can use TableAttribute and ColumnAttribute to override LightSpeed's inferred naming (we know it's called TableAttribute, but it does work for views as well!): [Table("vw_AllWidgets")] Reading between the lines, I'm wondering if you are asking about populating a data set that it doesn't make sense to model as an entity (because of denormalisation). You can do that using IUnitOfWork.Project, again just as if you were operating against a table, but that will only give you an IDataReader. Or you can use a LINQ anonymous type. However, if you are asking about performing a query against a denormalised view with no corresponding entity type, and capturing the results of that query into entity types, that's not supported. Or is it that you potentially have multiple views which would all map to the same entity type, but have different definitions, e.g. vw_AllWidgets, vw_RecentWidgets and vw_FaultyWidgets? If you think we're missing the point, then perhaps you could post the view(s) you want to query, and the entity model you want to populate from that view (or a simplified version -- it sounds like your real schemas may be pretty complicated!). Hopefully then we'll be able to give you some more definite advice. |
|
|
That answers my question, thx a lot.
Anthony |
|