Search Results

Search found 1103 results on 45 pages for 'eager evaluation'.

Page 8/45 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Using Include() with inherited entities problem

    - by Peter Stegnar
    In EF eager loading related entities is easy. But I'm having difficulties including inherited entities when loading data using table-per-type model. This is my model: Entities: ArticleBase (base article entity) ArticleSpecial (inherited from ArticleBase) UserBase (base user entity) UserSpecial (inherited from UserBase) Image Relations are as shown on the image (omitting many columns): In reality my users are always of type UserSpecial, since UserBase is used in another application, thus we can share credentials. That's the only reason I have two separate tables. UserBase table can't be changed in any way shape or form, because the other app would break. Question How am I suppose to load ArticleSpecial with both CreatedBy and EditedBy set, so that both are of type UserSpecial (that defines Image relation)? I've tried (unsuccessfully though) these options: 1. Using lambda expressions: context.ArticleBases .OfType<ArticleSpecial>() .Include("UserCreated.Image") .Include("UserEdited.Image"); In this case the problem is that both CreatedBy and EditedBy are related to UserBase, that doesn't define Image navigation. So I should somehow cast these two to UserSpecial type like: context.ArticleBases .OfType<ArticleSpecial>() .Include("UserCreated<UserSpecial>.Image") .Include("UserEdited<UserSpecial>.Image"); But of course using generics in Include("UserCreated<UserSpecial>.Image") don't work. 2. I have tried using LINQ query var results = from articleSpecial in ctx.ArticleBase.OfType<ArticleSpecial>() join created in ctx.UserBase.OfType<UserSpecial>().Include("Image") on articleSpecial.UserCreated.Id equals created.Id join edited in ctx.UserBase.OfType<UserSpecial>().Include("Image") on articleSpecial.UserEdited.Id equals edited.Id select articleSpecial; In this case I'm only getting ArticleSpecial object instances without related properties being set. I know I should select those somehow, but I don't know how? Select part in my LINQ could be changed to something like select new { articleSpecial, articleSpecial.UserCreated, articleSpecial.UserEdited }; but images are still not loaded into my context. My joins in this case are barely used to filter out articleSpecial results, but they don't load entities into context (I suppose). Can anybody provide any help regarding this problem? I think it's not so uncommon.

    Read the article

  • Evaluating software estimates: sure signs of unrealistic figures?

    - by Totophil
    Whilst answering “Dealing with awful estimates” posted by Ash I shared a few tips that I learned and personally use to spot weak estimates. But I am certain there must be many more! What heuristics to use in the scenario when one needs to make a quick evaluation of software project estimate that has been compiled by a third-party (a colleague, a business partner or an external company)? What are the obvious and not so obvious signs of weak software estimates that can be spotted without much detailed knowledge of task at hand?

    Read the article

  • Pros/Cons of switching from Exchange to GMail

    - by Brent
    We are a medium-large non-profit company, with around 1000 staff and volunteers, and have been using MS Exchange (currently 2003) for our mail system for years. I recently attended a Google conference where they were positing that "Cloud computing is the way of the future", and encouraging us to switch from doing our own email with Exchange, to using GMail and Google Apps for everything. Additionally, one of our departments has been pushing from inside to do this transition within their own department, if not throughout the entire organization. I can definitely see some benefits - such as: Archive space - we never seem to have the space our users want, and of course, the more we get, the more we have to back up OS Agnostic - Exchange is definitely built for windows, and with mac and linux users on the rise, these users increasingly demand better tools / support. Google offers this. Better archiving - potential of e-discovery, that doesn't exist in a practical way with our current setup. Switching would relieve us of a fair bit of server administration, give more options to our end users, and free up the server resources we are now using for Exchange. Our IT department wants to be perceived as providing up-to-date solutions to technical problems, and this change would definitely provide such an image. Google's infrastructure is obviously much more robust than ours, and they employ some of the world's best security and network experts. However, there are also some serious drawbacks: We would be essentially outsourcing one of our mission-critical systems to a 3rd party The switch would inevitably involve Google Apps and perhaps more as well. That means we would have a-lot more at the mercy of a single (potentially weak) password. (is there a way to make this more secure using a password plus physical key of some sort??) Our data would not remain under our roof - or even in our country (Canada). This obviously has plusses on the Disaster Recovery side, but I think there are potential negatives on the legal side. I can't imagine that somebody as large as Google would be as responsive as we would want with regard to non-critical issues such as tracing missing emails, etc. (not sure how much access we would have to basic mail logs - for instance) Can anyone help me evaluate this decision? What issues am I overlooking? What experiences have you had with this transition (or the opposite - gmail to Exchange) Can you add to the points I have already outlined?

    Read the article

  • A good file management/hosting/storage web service with embed-function?

    - by Andreas
    I am looking for a file management web service that lets me integrate the directory-view into a commercial website. Another requirement: User can register themselves, but need to be approved, before being able to download files. So something like box.net, but with more than just a a flash-widget. I would prefer some javascript, that can be embedded. Thanks for any recommendations.

    Read the article

  • Perl, evaluate string lazily

    - by Mike
    Consider the following Perl code. #!/usr/bin/perl use strict; use warnings; $b="1"; my $a="${b}"; $b="2"; print $a; The script obviously outputs 1. I would like it to be whatever the current value of $b is. What would be the smartest way in Perl to achieve lazy evaluation like this? I would like the ${b} to remain "unreplaced" until $a is needed.

    Read the article

  • SkyDrive : Microsoft fait une auto-évaluation de son service de stockage Cloud et souhaite renforcer celui-ci

    Skydrive : Microsoft fait une évaluation de son service de stockage Cloud et souhaite renforcer celui-ci SkyDrive, la solution de stockage des données en mode Cloud de Microsoft, bien qu'ayant subir plusieurs mises à jour et adopter le HTML5 pour son interface utilisateur, afin d'améliorer l'expérience d'accès et de partage des documents, présente encore des limites. Omar Shahine et Mike Torres, tous deux gestionnaires de programme pour Skydrive analysent dans un billet de blog l'univers des services Cloud en général, et Skydrive en particulier avec ses manquements et les futures améliorations qui seront apportées au service. Microsoft distingue tout d'abord trois types de...

    Read the article

  • Lazy Sequences that "Look Ahead" for Project Euler Problem 14

    - by ivar
    I'm trying to solve Project Euler Problem 14 in a lazy way. Unfortunately, I may be trying to do the impossible: create a lazy sequence that is both lazy, yet also somehow 'looks ahead' for values it hasn't computed yet. The non-lazy version I wrote to test correctness was: (defn chain-length [num] (loop [len 1 n num] (cond (= n 1) len (odd? n) (recur (inc len) (+ 1 (* 3 n))) true (recur (inc len) (/ n 2))))) Which works, but is really slow. Of course I could memoize that: (def memoized-chain (memoize (fn [n] (cond (= n 1) 1 (odd? n) (+ 1 (memoized-chain (+ 1 (* 3 n)))) true (+ 1 (memoized-chain (/ n 2))))))) However, what I really wanted to do was scratch my itch for understanding the limits of lazy sequences, and write a function like this: (def lazy-chain (letfn [(chain [n] (lazy-seq (cons (if (odd? n) (+ 1 (nth lazy-chain (dec (+ 1 (* 3 n))))) (+ 1 (nth lazy-chain (dec (/ n 2))))) (chain (+ n 1)))))] (chain 1))) Pulling elements from this will cause a stack overflow for n2, which is understandable if you think about why it needs to look 'into the future' at n=3 to know the value of the tenth element in the lazy list because (+ 1 (* 3 n)) = 10. Since lazy lists have much less overhead than memoization, I would like to know if this kind of thing is possible somehow via even more delayed evaluation or queuing?

    Read the article

  • Groovy as a substitute for Java when using BigDecimal?

    - by geejay
    I have just completed an evaluation of Java, Groovy and Scala. The factors I considered were: readability, precision The factors I would like to know: performance, ease of integration I needed a BigDecimal level of precision. Here are my results: Java void someOp() { BigDecimal del_theta_1 = toDec(6); BigDecimal del_theta_2 = toDec(2); BigDecimal del_theta_m = toDec(0); del_theta_m = abs(del_theta_1.subtract(del_theta_2)) .divide(log(del_theta_1.divide(del_theta_2))); } Groovy void someOp() { def del_theta_1 = 6.0 def del_theta_2 = 2.0 def del_theta_m = 0.0 del_theta_m = Math.abs(del_theta_1 - del_theta_2) / Math.log(del_theta_1 / del_theta_2); } Scala def other(){ var del_theta_1 = toDec(6); var del_theta_2 = toDec(2); var del_theta_m = toDec(0); del_theta_m = ( abs(del_theta_1 - del_theta_2) / log(del_theta_1 / del_theta_2) ) } Note that in Java and Scala I used static imports. Java: Pros: it is Java Cons: no operator overloading (lots o methods), barely readable/codeable Groovy: Pros: default BigDecimal means no visible typing, least surprising BigDecimal support for all operations (division included) Cons: another language to learn Scala: Pros: has operator overloading for BigDecimal Cons: some surprising behaviour with division (fixed with Decimal128), another language to learn

    Read the article

  • Consecutive calls/evaulations in a form?

    - by Dave
    Hey guys, simple question... Working with XLISP to write a program, but I've seemed to run into a simple fundamental problem that I can't seem to work around: perhaps someone has a quick fix. I'm trying to write an if statement who's then-clause evaluates multiple forms and returns the value of the last. In example: (setq POSITION 'DINING-ROOM) (defun LOOK (DIRECTION ROOM) ... ) (defun SETPOS (ROOM) ... ) (defun WHERE () ... ) (defun MOVE (DIRECTION) (if (not(equal nil (LOOK DIRECTION POSITION))) ; If there is a room in that direction ( ; Then-block: Go to that room. Return where you are. (SETPOS (LOOK DIRECTION ROOM)) (WHERE) ) ( ; Else-block: Return error (list 'CANT 'GO 'THERE) ) ) The logical equivalent intended is: function Move (Direction) { if(Look(Direction, Room) != null) { SetPos(Look(Direction,Room)); return Where(); } else { return "Can't go there"; } } (Apologies for the poor web-formatting.) The problem I have is with: ( (SETPOS (LOOK DIRECTION ROOM)) (WHERE) ) I simply want to return the evaluation of WHERE, but I need to execute the SETPOS function first. XLISP doesn't like the extra parentheses: if I remove the outer set, my WHERE list becomes my else (I don't want that). If I remove the sets around SETPOS and WHERE, it treats WHERE like an argument for SETPOS; I also don't want that. So, how do I simply evaluate the first, then the second and then return the values of the last evaluated?

    Read the article

  • Javascript Regex: Testing string for intelligent query

    - by Shyam
    Hi, I have a string that holds user input. This string can contain various types of data, like: a six digit id a zipcode that contains out of 4 digits and two alphanumeric characters a name (characters only) As I am using this string to search through a database, the query type is determined on the type of search, which i want to handle serverside using JavaScript (yes, I am using JavaScript serverside). Searching on StackOverflow, brought me some interesting information, like the .test-method, which seems perfect for my needs. The test-method returns either true or false based on the evaluation on the string using a regex object. I am using this page as a reference: http://www.javascriptkit.com/jsref/regexp.shtml So I am trying to determine the zipcode, by using the following very noobish regex. var r = /[A-Za-z]{2,2}/ As far I can understand, this should limit the amount of occurrences of alphanumeric characters to a maximum of two. See beneath the output of my JavaScript console. > var r = /[A-Za-z]{2,2}/ > var x = "2233AL" > r.test(x) true > var x = "2233A" > r.test(x) false > var x = "2233ALL" > r.test(x) true /* i want this to be false */ > A little help would be really appreciated!

    Read the article

  • Efficient counting of an association’s association

    - by Matthew Robertson
    In my app, when a User makes a Comment in a Post, Notifications are generated that marks that comment as unread. class Notification < ActiveRecord::Base belongs_to :user belongs_to :post belongs_to :comment class User < ActiveRecord::Base has_many :notifications class Post < ActiveRecord::Base has_many :notifications I’m making an index page that lists all the posts for a user and the notification count for each post for just that user. # posts controller @posts = Post.where( :user_id => current_user.id ) .includes(:notifications) # posts view @posts.each do |post| <%= post.notifications.count %> This doesn’t work because it counts notifications for all users. What’s an efficient way to do this without running a separate query for each post?

    Read the article

  • Session is Closed! NHibernate shouldn't be trying to grab data

    - by Jeremy Holovacs
    I have a UnitOfWork/Service pattern where I populate my model using NHibernate before sending it to the view. For some reason I still get the YSOD, and I don't understand why the object collection is not already populated. My controller method looks like this: public ActionResult PendingRegistrations() { var model = new PendingRegistrationsModel(); using (var u = GetUnitOfWork()) { model.Registrations = u.UserRegistrations.GetRegistrationsPendingAdminApproval(); } return View(model); } The service/unit of work looks like this: public partial class NHUserRegistrationRepository : IUserRegistrationRepository { public IEnumerable<UserRegistration> GetRegistrationsPendingAdminApproval() { var r = from UserRegistration ur in _Session.Query<UserRegistration>() where ur.Status == AccountRegistrationStatus.PendingAdminReview select ur; NHibernateUtil.Initialize(r); return r; } } What am I doing wrong?

    Read the article

  • NHibernateUtil.Initialize and Table where clause (Soft Delete)

    - by Pascal
    We are using NHibernate but sometimes manually load proxies using the NHibernateUtil.Initialize call. We also employ soft delete and have a "where" condition on all our mapping to tables. SQL generated by NHibernate successfully adds the where condition (i.e. DELETED IS NULL) however we notice that NHibernateUtil.Initialize does not observe the constraints of the mapping files. i.e. None of the SQL generated by NHibernateUtil.Initialize observes our DELETED IS NULL condition. Is there something we're missing as we would really like to employ manual loading of some entity collections when the situation demands it. We are using FluentNhibernate for our mapping.

    Read the article

  • LINQ-to-SQL eagerly load entire object graph

    - by Paddy
    I have a need to load an entire LINQ-to-SQL object graph from a certain point downwards, loading all child collections and the objects within them etc. This is going to be used to dump out the object structure and data to XML. Is there a way to do this without generating a large hard coded set of DataLoadOptions to 'shape' my data?

    Read the article

  • C# - Disable Dynamic Keyword

    - by chief7
    Is there any way to disable the use of the "dynamic" keyword in .net 4? I thought the Code Analysis feature of VS2010 might have a rule to fail the build if the dynamic keyword is used but I couldn't fine one.

    Read the article

  • How does 'lazy' work?

    - by Matt Fenwick
    What is the difference between these two functions? I see that lazy is intended to be lazy, but I don't understand how that is accomplished. -- | Identity function. id :: a -> a id x = x -- | The call '(lazy e)' means the same as 'e', but 'lazy' has a -- magical strictness property: it is lazy in its first argument, -- even though its semantics is strict. lazy :: a -> a lazy x = x -- Implementation note: its strictness and unfolding are over-ridden -- by the definition in MkId.lhs; in both cases to nothing at all. -- That way, 'lazy' does not get inlined, and the strictness analyser -- sees it as lazy. Then the worker/wrapper phase inlines it. -- Result: happiness Tracking down the note in MkId.lhs (hopefully this is the right note and version, sorry if it's not): Note [lazyId magic] ~~~~~~~~~~~~~~~~~~~ lazy :: forall a?. a? -> a? (i.e. works for unboxed types too) Used to lazify pseq: pseq a b = a `seq` lazy b Also, no strictness: by being a built-in Id, all the info about lazyId comes from here, not from GHC.Base.hi. This is important, because the strictness analyser will spot it as strict! Also no unfolding in lazyId: it gets "inlined" by a HACK in CorePrep. It's very important to do this inlining after unfoldings are exposed in the interface file. Otherwise, the unfolding for (say) pseq in the interface file will not mention 'lazy', so if we inline 'pseq' we'll totally miss the very thing that 'lazy' was there for in the first place. See Trac #3259 for a real world example. lazyId is defined in GHC.Base, so we don't have to inline it. If it appears un-applied, we'll end up just calling it. I don't understand that because it refers to lazyId instead of lazy. How does lazy work?

    Read the article

  • Rebuilding lazily-built attribute when an underlying attribute changes in Moose

    - by friedo
    I've got a Moose class with a lazy_build attribute. The value of that attribute is a function of another (non-lazy) attribute. Suppose somebody instantiates the class with a value of 42 for the required attribute. Then they request the lazy attribute, which is calculated as a function of 42. Then, they have the nerve to change the first attribute! The lazy one has already been built, so the builder will not get called again, and the lazy attribute is now out-of-date. I have a solution now where I maintain a "dirty" flag on the required attribute, and an accessor on the lazy one checks the dirty flag and rebuilds it if needed. However, this seems like a lot of work. Is there a way to handle this within Moose, e.g. using traits?

    Read the article

  • How to create static method that evaluates local static variable once?

    - by Viet
    I have a class with static method which has a local static variable. I want that variable to be computed/evaluated once (the 1st time I call the function) and for any subsequent invocation, it is not evaluated anymore. How to do that? Here's my class: template< typename T1 = int, unsigned N1 = 1, typename T2 = int, unsigned N2 = 0, typename T3 = int, unsigned N3 = 0, typename T4 = int, unsigned N4 = 0, typename T5 = int, unsigned N5 = 0, typename T6 = int, unsigned N6 = 0, typename T7 = int, unsigned N7 = 0, typename T8 = int, unsigned N8 = 0, typename T9 = int, unsigned N9 = 0, typename T10 = int, unsigned N10 = 0, typename T11 = int, unsigned N11 = 0, typename T12 = int, unsigned N12 = 0, typename T13 = int, unsigned N13 = 0, typename T14 = int, unsigned N14 = 0, typename T15 = int, unsigned N15 = 0, typename T16 = int, unsigned N16 = 0> struct GroupAlloc { static const uint32_t sizeClass; static uint32_t getSize() { static uint32_t totalSize = 0; totalSize += sizeof(T1)*N1; totalSize += sizeof(T2)*N2; totalSize += sizeof(T3)*N3; totalSize += sizeof(T4)*N4; totalSize += sizeof(T5)*N5; totalSize += sizeof(T6)*N6; totalSize += sizeof(T7)*N7; totalSize += sizeof(T8)*N8; totalSize += sizeof(T9)*N9; totalSize += sizeof(T10)*N10; totalSize += sizeof(T11)*N11; totalSize += sizeof(T12)*N12; totalSize += sizeof(T13)*N13; totalSize += sizeof(T14)*N14; totalSize += sizeof(T15)*N15; totalSize += sizeof(T16)*N16; totalSize = 8*((totalSize + 7)/8); return totalSize; } };

    Read the article

  • Iterator blocks in Clojure?

    - by Checkers
    I am using clojure.contrib.sql to fetch some records from an SQLite database. (defn read-all-foo [] (with-connection *db* (with-query-results res ["select * from foo"] (into [] res)))) Now, I don't really want to realize the whole sequence before returning from the function (i.e. I want to keep it lazy), but if I return res directly or wrap it some kind of lazy wrapper (for example I want to make a certain map transformation on result sequence), SQL-related bindings will be reset and connection will be closed after I return, so realizing the sequence will throw an exception. How can I enclose the whole function in a closure and return a kind of iterator block (like yield in C# or Python)? Or is there another way to return a lazy sequence from this function?

    Read the article

  • SQLiteException and SQLite error near "(": syntax error with Subsonic ActiveRecord

    - by nvuono
    I ran into an interesting error with the following LiNQ query using LiNQPad and when using Subsonic 3.0.x w/ActiveRecord within my project and wanted to share the error and resolution for anyone else who runs into it. The linq statement below is meant to group entries in the tblSystemsValues collection into their appropriate system and then extract the system with the highest ID. from ksf in KeySafetyFunction where ksf.Unit == 2 && ksf.Condition_ID == 1 join sys in tblSystems on ksf.ID equals sys.KeySafetyFunction join xval in (from t in tblSystemsValues group t by t.tblSystems_ID into groupedT select new { sysId = groupedT.Key, MaxID = groupedT.Max(g=>g.ID), MaxText = groupedT.First(gt2 => gt2.ID == groupedT.Max(g=>g.ID)).TextValue, MaxChecked = groupedT.First(gt2 => gt2.ID == groupedT.Max(g=>g.ID)).Checked }) on sys.ID equals xval.sysId select new {KSFDesc=ksf.Description, sys.Description, xval.MaxText, xval.MaxChecked} On its own, the subquery for grouping into groupedT works perfectly and the query to match up KeySafetyFunctions with their System in tblSystems also works perfectly on its own. However, when trying to run the completed query in linqpad or within my project I kept running into a SQLiteException SQLite Error Near "(" First I tried splitting the queries up within my project because I knew that I could just run a foreach loop over the results if necessary. However, I continued to receive the same exception! I eventually separated the query into three separate parts before I realized that it was the lazy execution of the queries that was killing me. It then became clear that adding the .ToList() specifier after the myProtectedSystem query below was the key to avoiding the lazy execution after combining and optimizing the query and being able to get my results despite the problems I encountered with the SQLite driver. // determine the max Text/Checked values for each system in tblSystemsValue var myProtectedValue = from t in tblSystemsValue.All() group t by t.tblSystems_ID into groupedT select new { sysId = groupedT.Key, MaxID = groupedT.Max(g => g.ID), MaxText = groupedT.First(gt2 => gt2.ID ==groupedT.Max(g => g.ID)).TextValue, MaxChecked = groupedT.First(gt2 => gt2.ID ==groupedT.Max(g => g.ID)).Checked}; // get the system description information and filter by Unit/Condition ID var myProtectedSystem = (from ksf in KeySafetyFunction.All() where ksf.Unit == 2 && ksf.Condition_ID == 1 join sys in tblSystem.All() on ksf.ID equals sys.KeySafetyFunction select new {KSFDesc = ksf.Description, sys.Description, sys.ID}).ToList(); // finally join everything together AFTER forcing execution with .ToList() var joined = from protectedSys in myProtectedSystem join protectedVal in myProtectedValue on protectedSys.ID equals protectedVal.sysId select new {protectedSys.KSFDesc, protectedSys.Description, protectedVal.MaxChecked, protectedVal.MaxText}; // print the gratifying debug results foreach(var protectedItem in joined) { System.Diagnostics.Debug.WriteLine(protectedItem.Description + ", " + protectedItem.KSFDesc + ", " + protectedItem.MaxText + ", " + protectedItem.MaxChecked); }

    Read the article

  • Does isEmpty method in Stream evaluate the whole Stream?

    - by abhin4v
    In Scala, does calling isEmtpy method on an instance of Stream class cause the stream to be evaluated completely? My code is like this: import Stream.cons private val odds: Stream[Int] = cons(3, odds.map(_ + 2)) private val primes: Stream[Int] = cons(2, odds filter isPrime) private def isPrime(n: Int): Boolean = n match { case 1 => false case 2 => true case 3 => true case 5 => true case 7 => true case x if n % 3 == 0 => false case x if n % 5 == 0 => false case x if n % 7 == 0 => false case x if (x + 1) % 6 == 0 || (x - 1) % 6 == 0 => true case x => primeDivisors(x) isEmpty } import Math.{sqrt, ceil} private def primeDivisors(n: Int) = primes takeWhile { _ <= ceil(sqrt(n))} filter {n % _ == 0 } So, does the call to isEmpty on the line case x => primeDivisors(x) isEmpty cause all the prime divisors to be evaluated or only the first one?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >