Search Results

Search found 9 results on 1 pages for 'schotime'.

Page 1/1 | 1 

  • parsing expression trees with booleans

    - by Schotime
    I am trying to parse an expression tree for a linq provider and running into a little snag with booleans. I can parse this no problems. var p = products.Where(x=>x.IsAvailable == true).ToList(); however when its written like this? var p = products.Where(x=>x.IsAvailable).ToList(); i only get a MemberAccess to look at and i can't see how i deduce that it is true or false (!x.IsAvailable). Any help would be great. Thanks.

    Read the article

  • Return nested alias for linq expression

    - by Schotime
    I have the following Linq Expression var tooDeep = shoppers .Where(x => x.Cart.CartSuppliers.First().Name == "Supplier1") .ToList(); I need to turn the name part into the following string. x.Cart.CartSuppliers.Name As part of this I turned the Expression into a string and then split on the . and removed the First() argument. However, when I get to CartSuppliers this returns a Suppliers[] array. Is there a way to get the single type from this. eg. I need to get a Supplier back. Thanks

    Read the article

  • Access the value of a member expression

    - by Schotime
    If i have a product. var p = new Product { Price = 30 }; and i have the following linq query. var q = repo.Products().Where(x=>x.Price == p.Price).ToList() In an IQueryable provider, I get a MemberExpression back for the p.Price which contains a Constant Expression, however I can't seem to get the value "30" back from it. Cheers.

    Read the article

  • What is the best way to handle multiple actions?

    - by Schotime
    Like most web applications you have a method that gets called when you log in. There are a few things that may need to get done when logged in and over time this may increase. eg. logging, welcome emails, maintenance. Should events be used to do this or is there a better way?? I'm using C# and ASP.net MVC.

    Read the article

  • Handling user security scope with nHibernate or other ORM

    - by Schotime
    How should one handle the situation where you may need to filter by a group of users. Here is the scenario. I have an administrator role in my company. I should be able to see all the data belonging to me plus all the other users who I have control over. A plain old user however should only be able to access their own data. If you are writing regular sql statements then you can have a security table with every user and who they have access too but i'm not sure how to handle this situation in the OO and ORM world. Any one dealt with this scenario in a web application using an ORM? Would love to hear your thoughts!

    Read the article

  • managing classes when everything is relative to a user in nhibernate (orm)

    - by Schotime
    Firstly I have three entities. Users, Roles, Items A user can have multiple Roles. An item gets assigned to one or more roles. Therefore a user will have access to a distinct set of items. Now there is a few ways I can see this working. There is a Collection on Users which has Roles via a many-to-many assoc. Then each Role in this collection will have its own collection of Items. So for each user I would have to get the User (using nhib and fetch the roles and items with it) then either do a selectMany on the Items in each Role to get all the Items for the user or do a couple of foreach's to port the data to a view or dto model. Create a db trigger to automatically insert into another table that just has the relationship between user and items so that on my User entity I only have a Items collections which has all the items assigned to me. Some other way that i can't think of yet, because I'm new to nHibernate. Now i know that the trigger doesn't feel right but I'm not sure how to do this. We also have some hierarchy later where a user may be in charge of a group of users. If anyone could shed some light on how they go about these scenarios in nhibernate or another orm that would be great, or point be in a direction. I know that in the past you would have to enter all combinations into a table so that the query worked, but when you know sql its not too bad. If you need any other info then let me know. Cheers

    Read the article

  • ASP.NET MVC - Entending the Authorize Attribute

    - by Mad Halfling
    Hi folks, currently I use [Authorize(Roles = ".....")] to secure my controller actions on my ASP.NET MVC 1 app, and this works fine. However, certain search views need to have buttons that route to these actions that need to be enabled/disabled based on the record selected on the search list, and also the security privs of the user logged in. Therefore I think I need to have a class accessing a DB table which cross-references these target controller/actions with application roles to determine the state of these buttons. This will, obviously, make things messy as privs will need to be maintained in 2 places - in that class/DB table and also on the controller actions (plus, if I want to change the access to the action I will have to change the code and compile rather than just change a DB table entry). Ideally I would like to extend the [Authorize] functionality so that instead of having to specify the roles in the [Authorize] code, it will query the security class based on the user, controller and action and that will then return a boolean allowing or denying access. Are there any good articles on this - I can't imagine it's an unusual thing to want to do, but I seem to be struggling to find anything on how to do it (could be Monday-morning brain). I've started some code doing this, looking at article http://schotime.net/blog/index.php/2009/02/17/custom-authorization-with-aspnet-mvc/ , and it seems to be starting off ok but I can't find the "correct" way to get the calling controller and action values from the httpContext - I could possibly fudge a bit of code to extract them from the request url, but that doesn't seem right to me and I'd rather do it properly. Cheers MH

    Read the article

1