Search Results

Search found 55 results on 3 pages for 'rockinthesixstring'.

Page 3/3 | < Previous Page | 1 2 3 

  • Linq To SQL: Retain list order when using .Contains

    - by rockinthesixstring
    I'm using Lucene.net to build a MyListOfIds As List(Of Integer) which I then pass on to my Linq service. I then search the database as follows Return _EventRepository.Read().Where(Function(e) MyListOfIds.Contains(e.ID)).ToList Now I know that Lucene is already ordering MyListOfIds based on the weight it gave each term. What sucks is that Linq is losing that order in it's SQL search. My Question: How can I retain that sort order when building my Lambda expression? I tried using LINQPad to see how the query is being built, but because I had to declare a variable LINQPad didn't show me the resultant SQL :-( Here's what I tried in LINQPad Dim i As New List(Of Integer) i.Add(1) i.Add(100) i.Add(15) i.Add(3) i.Add(123) Dim r = (From e In Events Where i.Contains(e.ID) Select e) note: my example is in VB.NET, but I don't mind if responses are in C#

    Read the article

  • Need help profiling .NET caching extension method.

    - by rockinthesixstring
    I've got the following extension Public Module CacheExtensions Sub New() End Sub Private sync As New Object() Public Const DefaultCacheExpiration As Integer = 1200 ''# 20 minutes <Extension()> Public Function GetOrStore(Of T)(ByVal cache As Cache, ByVal key As String, ByVal generator As Func(Of T)) As T Return cache.GetOrStore(key, If(generator IsNot Nothing, generator(), Nothing), DefaultCacheExpiration) End Function <Extension()> Public Function GetOrStore(Of T)(ByVal cache As Cache, ByVal key As String, ByVal generator As Func(Of T), ByVal expireInSeconds As Double) As T Return cache.GetOrStore(key, If(generator IsNot Nothing, generator(), Nothing), expireInSeconds) End Function <Extension()> Public Function GetOrStore(Of T)(ByVal cache As Cache, ByVal key As String, ByVal obj As T) As T Return cache.GetOrStore(key, obj, DefaultCacheExpiration) End Function <Extension()> Public Function GetOrStore(Of T)(ByVal cache As Cache, ByVal key As String, ByVal obj As T, ByVal expireInSeconds As Double) As T Dim result = cache(key) If result Is Nothing Then SyncLock sync If result Is Nothing Then result = If(obj IsNot Nothing, obj, Nothing) cache.Insert(key, result, Nothing, DateTime.Now.AddSeconds(expireInSeconds), cache.NoSlidingExpiration) End If End SyncLock End If Return DirectCast(result, T) End Function End Module From here, I'm using the extension is a TagService to get a list of tags Public Function GetTagNames() As List(Of String) Implements Domain.ITagService.GetTags ''# We're not using a dynamic Cache key because the list of TagNames ''# will persist across all users in all regions. Return HttpRuntime.Cache.GetOrStore(Of List(Of String))("TagNamesOnly", Function() _TagRepository.Read().Select(Function(t) t.Name).OrderBy(Function(t) t).ToList()) End Function All of this is pretty much straight forward except when I put a breakpoint on _TagRepository.Read(). The problem is that it is getting called on every request, when I thought that it is only to be called when Result Is Nothing Am I missing something here?

    Read the article

  • DotNet Get User Operating System (HTTP_USER_AGENT)

    - by rockinthesixstring
    I'm looking at building an exhaustive function that returns a friendly name for the Users Operating System. I think I have most of the Windows stuff down, but I'm not sure about Linux, OSX, and others. Does anyone know where I can find an exhaustive list of HTTP_USER_AGENT's 'Gets the users operating system Public Shared Function GetUserOS() As String Dim strAgent As String = HttpContext.Current.Request.ServerVariables("HTTP_USER_AGENT") 'Windows OS's If InStr(strAgent, "Windows NT 6.1") Then : Return "Windows 7" ElseIf InStr(strAgent, "Windows NT 6.0") Then : Return "Windows Vista" ElseIf InStr(strAgent, "Windows NT 5.2") Then : Return "Windows Server 2003" ElseIf InStr(strAgent, "Windows NT 5.1") Then : Return "Windows XP" ElseIf InStr(strAgent, "Windows NT 5.0") Then : Return "Windows 2000" ElseIf InStr(strAgent, "Windows 98") Then : Return "Windows 98" ElseIf InStr(strAgent, "Windows 95") Then : Return "Windows 95" 'Mac OS's ElseIf InStr(strAgent, "Mac OS X") Then : Return "Mac OS X" 'Linux OS's ElseIf InStr(strAgent, "Linux") Then : Return "Linux" Else : Return "Unknown" End If End Function 'GetUserOS

    Read the article

  • ASP.NET - How can I cache user details for the duration of their visit?

    - by rockinthesixstring
    I've built a Repository that gets user details Public Function GetUserByOpenID(ByVal openid As String) As User Implements IUserRepository.GetUserByOpenID Dim user = (From u In dc.Users Where u.OpenID = openid Select u).FirstOrDefault Return user End Function And I'd like to be able to pull those details down IF the user is logged in AND IF the cached data is null. What is the best way to create a User object that contains all of the users details, and persist it across the entire site for the duration of their visit? I Was trying this in my Global.asax, but I'm not really happy using Session variables. I'd rather have a single object with all the details inside. Private Sub BaseGlobal_AcquireRequestState(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.AcquireRequestState If Session("UserName") Is Nothing AndAlso User.Identity.IsAuthenticated Then Dim repo As UrbanNow.Core.IUserRepository = New UrbanNow.Core.UserRepository Dim _user As New UrbanNow.Core.User _user = repo.GetUserByOpenID(User.Identity.Name) Session("UserName") = _user.UserName() Session("UserID") = _user.ID End If End Sub

    Read the article

  • jQuery: How can I get the HTML from one div to display in another.

    - by rockinthesixstring
    I've got a small script that detects if the user is using Google Chrome var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; if(is_chrome){ $('.ifChrome').attr('style', 'display:block;'); $('.ifChrome').html($('noscript > div').html()); }; If they are using chrome, we want to display a div tag and show the HTML from a different div tag inside. <noscript> <div class="note"> Your browser does not properly support the WMD Markdown Editor.<br /> Please use <a href="/about/markdown" target="_blank">Markdown<.a> to style your input. </div> </noscript> <div class="hidden ifChrome note"></div> What I'm trying to do is show the "not supported" text from inside my <noscript> tag to users who are using google Chrome (because WMD Markdown doesn't work properly with Chrome). My existing Javascript is not working. Any help would be greatly appreciated.

    Read the article

< Previous Page | 1 2 3