Hi, I'm quite new to Silverlight and DevForce . I fully understand how I can do LINQs to Entities at client side. However in my applications I have many queries that are of such nature that I have to do many queries first before I return the real data to the client. It is obvious that it is more appropirate doing all those server side to minimize round trips from client to server: Here is a small example
I did for tesint using a console app.:
private static void GetCustomers(string userID)
{
var userQ = (from user in m_mgr.EntUserSet
where user.p_userID == userID
select new {user, userGroups = user.p_UserGroups}).FirstOrDefault();
var userGroups = (from u in userQ.userGroups
select u.p_userID).ToList();
userGroups.Add(userID);
var customerIDs = m_mgr.EntPointGroupAccessSet
.WhereIn( e => e.p_userID , userGroups )
.Select( e => new {customerID = e.p_customerID} ).Distinct();
var customerQ = m_mgr.EntCustomerSet
.OrderBy(c => c.p_name)
.WhereIn(c => c.p_customerID, (from d in customerIDs select d.customerID).ToArray());
foreach( EntCustomer c in customerQ )
{
Console.WriteLine( "Customer = " + c.p_name );
Console.WriteLine();
}
}
Now I want to move this functionalety to my Sileverlight app. Only the result of customerQ (the red one) is of importance at the client side. It would be redicelous to run the other 3 queries on client side that are only used to get parmeters for the customerQ.
What is the best practise to implement such server side functions (GetCustomers(string userID)) server side and how to call those client side. Probably it is right to call InvokeServerMethodAsync() used client side, but how and where should I implement the GetCustomers(string userID) server side? Should it be implemented as a member of EntCustomers?...hardly becuase do not have anyaccess to EnCustomerSet there.
PS: the WhereIn function above is a "QueriableExetension" to implement the common IN of SQL not currently available in LINQ to entites...This only creates an Or-squence.