I am working on a project that groups data by "customer ID" when the user logs in, They are limited to that customer and the customer.
I am working with Subsonic 3, and what I have seen looks like this:
public IEnumerable & lt; Models.Foo & gt; FindFoo (int userID, string search text, int page index, int page size) Return to the item in Foo.GetPaged (page indexes, pagescases) where (itemName.Contains (searchText)) item.Description.Contains (searchText)) & Amp; & Amp; Item.CustomerID == CurrentCustomerID () Select new model. Foo (item); }
What I would like to do, is the essence away from the item. Customer ID line, because this is happening because the every query is failing, so it's easy to do in one place (and more secure) and it will be everywhere.
So, I have a question: can this be done, and if so, how?
As far as the subsonic generated classes are partly, you can add some interfaces to them ... just You can create an interface with the customer ID (for example, this ICusomerEntity
) and partly for any generated classes, they will implement this interface ... then only ICustomerEntity Use normal subsonic methods to retrieve
, not a specific class.
Example You can make a generic method called GetCustomerEntity called T: ICustomerEntity
, which is an I user ..
It helps ...
< / Div>
Comments
Post a Comment