﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - Crosslight - How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Wed, 28 Jan 2015 11:15:55 GMT</pubDate><dc:creator>technical@intersoftpt.com</dc:creator><description>&lt;p&gt;Hello Jimmy,&lt;/p&gt;&lt;p&gt;I was previously assuming that you already have a custom way to call the SP. Our best practice is usually generating the functions automatically from the EDMX to avoid mistakes in parameters definition, which is also goodfor maintenance. When the specific SP is added to the EDMX, Intersoft Entity Designer will automatically generate the code in both EntityContext and in the Controller. Technically, the underlying code in the EntityContext actually use "Context" to perform the SP call which is completely fine since it routes the call to SP directly without requiring LINQ.&lt;/p&gt;&lt;p&gt;You can then simply call the SP in your query method such as shown in the simple code snippet below:&lt;/p&gt;&lt;pre&gt;&lt;br&gt;&lt;br&gt;[HttpGet]public QueryResult ItemsByName(string name, ODataQueryOptions&amp;lt;Item&amp;gt; options)
{
    return new QueryResult()
    {
        Results = this.GetItemsByName(name), 
        InlineCount = this.Request.GetInlineCount() 
    };
}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;In the above example, the query calls the GetItemsByName method which was an auto-generated method fromthe Intersoft Entity Designer.&lt;/p&gt;&lt;p&gt;However, please note that the InlineCount might not work using the built-in Request.GetInlineCount method since the actual query is performed with a custom SP. In that case, you'll need to come up with another SP that returns the total number of rows of the query. But, if the app doesn't require paging, then InlineCount is not required.&lt;/p&gt;&lt;p&gt;Hope this helps!&lt;/p&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Wed, 28 Jan 2015 06:57:33 GMT</pubDate><dc:creator>jtungol@silentpartnersoft.com</dc:creator><description>Hmmm... how do you call an SP without executing the query using db.Context? When calling the desired SP and passing the needed parameters manually, isn't it that db.Context is still required? A code snippet would be very much appreciated. There may be several ways of calling an SP, but could you please post a code that demonstrates your feedback?&lt;br&gt;&lt;br&gt;We can think of using &lt;span style="font-weight: bold;"&gt;db.Context.Database.SqlQuery&amp;lt;TModel&amp;gt;("GetCategoryByLocations", params[])&lt;/span&gt; based on your statement. But even that makes use of the db.Context. So please... pretty please confirm or provide a code snippet regarding your latest post.&lt;br&gt;&lt;br&gt;Much appreciated. Many thanks!&lt;br&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Tue, 27 Jan 2015 17:29:57 GMT</pubDate><dc:creator>technical@intersoftpt.com</dc:creator><description>&lt;p&gt;Hello Jimmy,&lt;/p&gt;&lt;p&gt;The incremental loading, filtering and paging are actually features that were built into the EntityController. Behind the scene, the options passed from the client is transformed into LINQ expression which is then sent to theserver for execution.&lt;/p&gt;&lt;p&gt;Per our experience, it will be quite tedious to achieve these functions at SP level, since you need to parse each option and apply it to your query subsequently.&lt;/p&gt;&lt;p&gt;However, let's say you already managed to implement the functions at SP, you can continue using QueryResult using the same method signature. But, instead of executing the query using db.Context, you call the desired SP and pass the needed parameters manually. Once your query returns, pass the result (should be either IList orIEnumerable) to the Results property of the QueryResult. This should allow the method to be still compatible withe client request, while at the same time enable you to use custom SP call in the server.&lt;/p&gt;&lt;p&gt;Hope this helps.&lt;/p&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Fri, 23 Jan 2015 22:20:51 GMT</pubDate><dc:creator>jtungol@silentpartnersoft.com</dc:creator><description>We believe &lt;span style="font-weight: bold;"&gt;item #2&lt;/span&gt; is supported, and have made it work. However, please do advise follow-up queries regarding &lt;span style="font-weight: bold;"&gt;item #1&lt;/span&gt;, as to how we can use &lt;span style="font-weight: bold;"&gt;ObjectResult&amp;lt;TEntityModel&amp;gt; GetCategoryByLocations(string location)&lt;/span&gt;. We can extend this Crosslight-generated function to &lt;span style="font-weight: bold;"&gt;QueryResult &lt;/span&gt;using a partial class, but that breaks the paging or incremental loading, because the controller does not recognize the query string syntax (see attached screenshot). We might prefer to use stored procedures often for complex queries with &lt;span style="font-weight: bold;"&gt;EnableIncrementalLoading&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;EnableRefresh&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;EnableAsyncFilter&lt;/span&gt;, and &lt;span style="font-weight: bold;"&gt;ExitEditModeOnDelete &lt;/span&gt;set to true. So please, kindly advise what we need to do next or provide a link that specifically demonstrate how to use custom functions and stored procedures (if any). If not, code snippets would work as well.&lt;br&gt;&lt;br&gt;Thanks!&lt;br&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Fri, 23 Jan 2015 10:04:37 GMT</pubDate><dc:creator>jtungol@silentpartnersoft.com</dc:creator><description>Hi Yudi,&lt;br&gt;&lt;br&gt;Thanks for your feedback... and we appreciate the samples you have given. However there are still unasnwered queries regarding this matter.&lt;br&gt;&lt;br&gt;I'm not sure we were able to get answers with &lt;span style="font-weight: bold;"&gt;item #2 (Display text from related Entity)&lt;/span&gt;. Did you get a chance to review it? Kindly confirm if that's possible at all. Will the navigation work for related entities in this case, cosidering the sample tables/entities we provided?&lt;br&gt;&lt;br&gt;In addition to&lt;span style="font-weight: bold;"&gt; item #1&lt;/span&gt;. Does the return type needs to be specified of type &lt;span style="font-weight: bold;"&gt;QueryResult&lt;/span&gt;? What about those that were auto-generated by Crosslight to use stored procedures such as &lt;span style="font-weight: bold;"&gt;ObjectResult&amp;lt;Category&amp;gt; GetCategoryByLocations(string location)&lt;/span&gt;? How do we take advantage of this instead of the custom or extended method you've shown?&lt;br&gt;&lt;br&gt;Please advise. Thanks!&lt;br&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Mon, 12 Jan 2015 10:11:22 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Sorry for the delay in sending this.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Please obtain the sample in &lt;a href="http://git.intersoftpt.com/projects/CROS-SUPP/repos/android-filter-data-using-subquery/browse" target="_blank"&gt;here&lt;/a&gt; and let us know whether it helps or not.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Thu, 08 Jan 2015 00:31:23 GMT</pubDate><dc:creator>jtungol@silentpartnersoft.com</dc:creator><description>&lt;p&gt;Hi Yudi,&lt;/p&gt;&lt;p&gt;Thanks for your feedback. Please do provide the sample solution for this sample.&lt;/p&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Tue, 06 Jan 2015 11:18:14 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="color: #1f497d;"&gt;First, Sorry for the delay in sending this.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #1f497d;"&gt;To filter data using subquery should be done in server. We need to:&lt;/span&gt;&lt;/p&gt;
&lt;ul style="color: #1f497d;"&gt;&lt;li&gt;create/modify a method in server and do subquery&lt;/li&gt;&lt;li&gt;using ServiceDescriptor in Core project (client) to construct the request&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;In my end, I create a project using Business project template and filter Category data using subquery with a simple condition: the app will list categories in a selection list where location is equal to "My Room". Location in my project is a field from Items table (related table)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Following snippet is added into the Controller class.&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;[HttpGet]
public QueryResult CategoriesByLocation(string location, ODataQueryOptions&amp;lt;Category&amp;gt; options)
{
        EntityContextProvider&amp;lt;InventoryEntities&amp;gt; db2 = new EntityContextProvider&amp;lt;InventoryEntities&amp;gt;();
        List&amp;lt;Item&amp;gt; items = db2.Context.Items.Where(o =&amp;gt; o.Location == location).ToList();

    //List&amp;lt;int&amp;gt; categories = items.Select(o =&amp;gt; o.CategoryID).Distinct().ToList();

    List&amp;lt;int&amp;gt; categories = new List&amp;lt;int&amp;gt;();
    foreach (var item in items)
    {
        if (!categories.Contains(item.CategoryID))
            categories.Add(item.CategoryID);
    }


    var query = db.Context.Categories.Where(o =&amp;gt; categories.Contains(o.CategoryID));
    IQueryable results = options.ApplyTo(query);
    return new QueryResult { Results = results, InlineCount = this.Request.GetInlineCount() };
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;The subquery is done in here. This request: http://[server url]/data/inventory/categoriesbylocation?location=My%20Room will be handled by CategoriesByLocation().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;In client, we can use ServiceDescriptor to contruct the request. Simply add following snippet code in ViewModel.&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;public CategoryListViewModel()
{
    this.ServiceDescriptor = new ServiceDescriptor();
    this.ServiceDescriptor.Parameters.Add("location", "My Room");
    this.ServiceDescriptor.ServiceName = "CategoriesByLocation";
    this.ServiceDescriptor.HttpMethod = HttpMethod.GET;
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Hope this help. I will prepare the sample that I used in my local end to be uploaded soon.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>How to Use Crosslight Enterprise Framework and Related Tables?</title><link>http://www.intersoftsolutions.com/Community/Crosslight/How-to-Use-Crosslight-Enterprise-Framework-and-Related-Tables/</link><pubDate>Mon, 29 Dec 2014 17:13:00 GMT</pubDate><dc:creator>jtungol@silentpartnersoft.com</dc:creator><description>&lt;p&gt;Hi Guys,&lt;/p&gt;&lt;p&gt;How do use Crosslight's Enterprise Framework to &lt;span style="font-weight: bold;"&gt;display text from a related table&lt;/span&gt;, and &lt;span style="font-weight: bold;"&gt;filter data using a subquery&lt;/span&gt;? Say for instance, we have a main table or entity called &lt;span style="font-weight: bold;"&gt;Location&lt;/span&gt; with fields such as &lt;em&gt;LocationID, LocationName, Address, City, State, and Zip&lt;/em&gt;. Another entity is called &lt;span style="font-weight: bold;"&gt;Tickets&lt;/span&gt;, which has fields called &lt;em&gt;TicketID, LocationID, UserID, Commission, Tax, Expense, Gross, DateCollected, and CollectionDate&lt;/em&gt;, where LocationID is a foreign key related to &lt;span style="font-weight: bold;"&gt;Location&lt;/span&gt; entity with one to many relationship... and UserID is a foreign key related to the &lt;span style="font-weight: bold;"&gt;User&lt;/span&gt; entity that was adopted from "&lt;a href="http://developer.intersoftpt.com/display/crosslight/User+Management+and+Authentication" target="_blank"&gt;User Management ang Authentication&lt;/a&gt;".&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Filter Data Using a Subquery&lt;/span&gt;. Once the app loads, it will load a list of Tickets that are not yet collected (DateCollected is null) and UserID is equal to the logged user. This should be straight forward using the QueryDefition. Now, when you add a new Ticket the user needs to select a Location (much like the Category &lt;span style="font-weight: bold;"&gt;selection list&lt;/span&gt; from your samples). The issue that we are facing is... the app should only list Locations in a selection list that do not have uncollected Tickets. The query looks like this... &lt;em&gt;SELECT * FROM Location WHERE LocationID NOT IN (SELECT LocationID FROM Ticket WHERE DateCollected IS NULL AND UserID = @UserID)&lt;/em&gt;. How do we implement this type of filters, while the EditableEntityRepository that was generated by the Intersoft loads all location?&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Display Text from Related Entity&lt;/span&gt;. We believe this is supported... but not sure sure which sample can we use as reference to achieve this. When the list of Tickets is loaded by the application using DataListViewModelBase, we need to display the &lt;span style="font-weight: bold;"&gt;LocationName &lt;/span&gt;as the DisplayMemberPath, and concatenated (Address, City, State, and Zip) or &lt;span style="font-weight: bold;"&gt;FullAddress&lt;/span&gt; as the DetailMemberPath. Looking at some samples, we understand that we can use Location partial class to implement the FullAddress, but will it work if we specify DisplayMemberPath = "Location.LocationName" and DetailMemberPath = "Location.FullAddress" in an ItemBindingDescription object for the TicketListBindingProvider?&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Please advise. A sample for these kinds of scenarios would be nice. Thanks!&lt;br&gt;&lt;/p&gt;</description></item></channel></rss>