Search Results

Search found 129 results on 6 pages for 'andrey s petrov'.

Page 5/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Entity framework 4.0 compiled query with Where() clause issue

    - by Andrey Salnikov
    Hello, I encountered with some strange behavior of System.Data.Objects.CompiledQuery.Compile function - here is my code for compile simple query: private static readonly Func<DataContext, long, Product> productQuery = CompiledQuery.Compile((DataContext ctx, long id) => ctx.Entities.OfType<Data.Product>().Where(p => p.Id == id) .Select(p=>new Product{Id = p.Id}).SingleOrDefault()); where DataContext inherited from ObjectContext and Product is a projection of POCO Data.Product class. My data context in first run contains Data.Product {Id == 1L} and in second Data.Product {Id == 2L}. First using of compilled query productQuery(dataContext, 1L) works perfect - in result I have Product {Id == 1L} but second run productQuery(dataContext, 2L) always returns null, instead of context in second run contains single product with id == 2L. If I remove Where clause I will get correct product (with id == 2L). It seems that first id value caching while first run of productQuery, and therefore all further calls valid only when dataContext contains Data.Product {id==1L}. This issue can't be reproduced if I've used direct query instead of its precompiled version. Also, all tests I've performed on test mdf base using SQL Server 2008 express and Visual studio 2010 final from my ASP.net application.

    Read the article

  • Tomcat custom 404 not shown

    - by Andrey
    Hello! In my web.xml I am using <error-page> <error-code>404</error-code> <location>/static/404.html</location> </error-page> but is doesn't work in Tomcat. It still shows the Tomcat's default 404 page. And no - that's not IE. I tried different browsers. /static/404.html opens if requested directly. Any ideas? Thanks in advance!

    Read the article

  • Passing contextual info to Views in ASP.NET MVC

    - by Andrey
    I wonder - what is the best way to supply contextual (i.e. not related to any particular view, but to all views at the same time) info to a view (or to master page)? Consider the following scenario. Suppose we have an app that supports multiple UI languages. User can switch them via UI's widgets (something like tabs at the top of the page). Each language is rendered as a separate tab. Tab for the current language should not be rendered. To address these requirements I'm planning to have a javascript piece that will hide current's language tab on the client. To do this, I need current's language tab Id on the client. So, I need some way of passing the Id to master page (for it to be 'fused' into the js script). The best thing I can think of is that all my ViewModels should inherit some ViewModeBase that has a field to hold current language tab Id. Then, whatever View I'm rendering, this Id will always be available for the master page's hiding script. However, I'm concerned that this ViewModelBase can potentially grow in an uncontrolled fashion as number of such pieces of contextual info (like current language) will grow.. Any ideas?

    Read the article

  • django image managment

    - by Andrey
    I'am new in django. In my project I'am working with images. I don't know how to organize the management of images. I need to dynamically upload the pictures and resize them. First question - what is the best way to dynamically upload images with progress bar and without flash? I found this and this, but I believe there is a better way. Second question. I have to save one image in different sizes. I won't use these thumbnails on my pages, but another application will. Many clients could upload images at the same time. This means that I can not resize all the images at the same time. How should I organize this process? Is there are a better ready-to-use solution for image management issue?

    Read the article

  • Creating a sort function for a generic list

    - by Andrey
    I have a method for sorting generic lists by the object fields: public static IQueryable<T> SortTable<T>(IQueryable<T> q, string sortfield, bool ascending) { var p = Expression.Parameter(typeof(T), "p"); if (typeof(T).GetProperty(sortfield).PropertyType == typeof(int?)) { var x = Expression.Lambda<Func<T, int?>>(Expression.Property(p, sortfield), p); if (ascending) q = q.OrderBy(x); else q = q.OrderByDescending(x); } else if (typeof(T).GetProperty(sortfield).PropertyType == typeof(int)) { var x = Expression.Lambda<Func<T, int>>(Expression.Property(p, sortfield), p); if (ascending) q = q.OrderBy(x); else q = q.OrderByDescending(x); } else if (typeof(T).GetProperty(sortfield).PropertyType == typeof(DateTime)) { var x = Expression.Lambda<Func<T, DateTime>>(Expression.Property(p, sortfield), p); if (ascending) q = q.OrderBy(x); else q = q.OrderByDescending(x); } // many more for every type return q; } Is there any way I can collapse those ifs to a single generic statement? The main problem is that for the part Expression.Lambda<Func<T, int>> I am not sure how to write it generically.

    Read the article

  • Applet in client-server infrastructure

    - by Andrey
    Hello! I have a general question concerning client-server design. We have a Java server with Spring, a GWT client program and some HTTP-servlets for our site. At the moment we also want to develop an applet which would communicate with that server in such a way GWT-client and site requests do. Is it a good idea to communicate with the server from applet by RMI? I.e. to create some Remote services, register them with Spring and call them from applet? Thanks in advance!

    Read the article

  • Use AttachedProperty in Style in ControlTemplate

    - by Andrey
    Here is my simple app: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:app="clr-namespace:WpfApplication1" Title="Window1" Height="300" Width="300"> <Window.Resources> <Style x:Key="Test"> <Setter Property="Button.Template"> <Setter.Value> <ControlTemplate> <Border BorderBrush="Blue" BorderThickness="3" Background="Black" CornerRadius="{Binding app:Extras.CornerRadius}" > </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <Button Height="23" HorizontalAlignment="Left" Margin="29,26,0,0" Name="button1" VerticalAlignment="Top" Width="75" app:Extras.CornerRadius="10" Style="{StaticResource Test}" >Button</Button> </Grid> </Window> Here is my AttachedPropery: namespace WpfApplication1 { public class Extras { public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached( "CornerRadius", typeof(double), typeof(Button), new FrameworkPropertyMetadata(1.0d, FrameworkPropertyMetadataOptions.AffectsRender) ); public static void SetCornerRadius(UIElement element, double value) { element.SetValue(CornerRadiusProperty, value); } public static double GetCornerRadius(UIElement element) { return (double)element.GetValue(CornerRadiusProperty); } } } CornerRadius="{Binding app:Extras.CornerRadius}" this of course doesn't work. so how can I get value from here app:Extras.CornerRadius="10" thanks in advance!

    Read the article

  • For each level of factor aggregate values over all levels except the current one (in R)

    - by Andrey Chetverikov
    For each level of factor I need to extract values aggregated over all subsets of data.frame except the current one. For example, there is a several subjects doing a reaction time task during several days, and I need to compute mean reaction time for all subjects and all days, but not including the subject for whom the mean is computed. Currently, I do it like this: library(lme4) ddply(sleepstudy, .(Subject, Days), summarise , avg_rt=mean(sleepstudy[sleepstudy$Subject!=Subject&sleepstudy$Days==Days,"Reaction"]), .progress="text") It works fine for small data sets, but for large ones it can be very slow. Is there a way to do it faster?

    Read the article

  • Unity 2.0. How to throw ResolutionFailedException

    - by Andrey Khataev
    Hello, I have my app, using functionality that is based on unity application block. Sometimes I need to throw ResolutionFailedException manually. In v1.2 constructor of ResolutionFailedException had three parameters - typerequested, namerequested and exception. In v2.0 fourth parameter was added - buildercontext. I'm not creating it manually, so I have no reference to it and no idea where I can get it. Roughly speaking, I'm only overriding Resolve method in particular way and I'm not interfere in standard mechanism of policies, strategies and so on. Could anyone help?

    Read the article

  • Detect if a method was overridden using Reflection (C#)

    - by Andrey
    Say I have a base class TestBase where I define a vistual method TestMe() class TestBase { public virtual bool TestMe() { } } Now I inherit this class: class Test1 : TestBase { public override bool TestMe() {} } Now, using Reflection, I need to find if the method TestMe has been overriden in child class - is it possible? What I need it for - I am writing a designer visualizer for type "object" to show the whole hierarchy of inheritance and also show which virtual methods were overridden at which level.

    Read the article

  • One-to-many relationship related to many tables

    - by Andrey
    I have a scenario where: there are two (or more) tables that represent independent items. lets say Users and Companies Both of these tables need addresses stored. Each one can have one or more address In a normal 1 to many scenario Addresses table woudl just have a UserId or a CompanyId creating a normal 1 to many relationship. In this case i have a few approaches i can think of the Addresses table could have both a UserId and a CompanyId and only one would be used for each record. 2 keys could be used ObjectId and ObjectType So Object id would have a UserId or a CompanyId, and ObjectType woudl be User or Company Create an ObjectTable and add ObjectId to Users and Companies. Addresses would then have an OjbectId I do not really like any of these solutions. i am wondering what is the best approach here. On another note i will most likely user linqtosql for my data access layer.

    Read the article

  • Reference to an instance method of a particular object

    - by Andrey
    In the following code, if i try to pass method reference using the class name, works. But passing the reference variable compiler gives an error, i do not understand why? public class User { private String name; public User(String name) { this.name = name; } public void printName() { System.out.println(name); } } public class Main { public static void main(String[] args) { User u1 = new User("AAA"); User u2 = new User("BBB"); User u3 = new User("ZZZ"); List<User> userList = Arrays.asList(u1, u2, u3); userList.forEach(User::printName); // works userList.forEach(u1::printName); // compile error } } Thanks,

    Read the article

  • String generator issue

    - by Andrey
    I want to write a method which returns a string. So far so good. The creation of the string however is quite complicated. I have 3 string lists - the first one has 155 entries, the second one - 9, the third one 21. I want my method if called enough times(155*9*21) to return all the possible combinations of values from the 3 lists (basically this method should keep count on how many times it was called and return only one combination each time). Any ideas how to accomplish that? I have 155*9*22 possible combinations. The first time the method is called it should take List1(0), List2(0), List3(0). After that in the next 21 iterations, the index of the third list is only changed. Once all the elements from the third list have been used increment the index of the second list and so on. Once the method has produced all the possible combinations (155*9*22) I want it to start from the beginning.

    Read the article

  • FTP: check whether file is closed

    - by Andrey
    Hello! My FTP client (apache commons ftpclient) needs to download file from FTP. The problem is that an external service may not have finished writing to this file before I start downloading. Is there any way to determine via FTP whether the file is already closed (i.e. there is no writing handlers opened)? The problem is that I cannot synchronize with that external service. But I mustn't download file which is not finished yet (a large JPEG). Thanks in advance!

    Read the article

  • Strange macro declaration in C

    - by Andrey Atapin
    Exploring libusb-1.0.9 source code, I have found such line (./os/poll_windows.c:78): #define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0) As for me this is the same like: #define CHECK_INIT_POLLING if(!is_polling_set) init_polling(); Is there any reason to loop that expression? UPDATE: I couldn't still realize what'd be wrong after the answers, and the following example helped: #include <stdio.h> #define TEST if(test) foo(); #define TEST_DO do { if(test) foo(); } while(0) int test = 1; void foo() { printf("%s", "Foo called"); } int main(int argc, char** argv) { if(argc > 1) TEST_DO; /* LINE 12 */ else printf("%s", "skipping..."); return 0; } If you put TEST at line 12, a compiler will give an error "error: ‘else’ without a previous ‘if’". Hope, this will help someone.

    Read the article

  • for loop vs std::for_each with lambda

    - by Andrey
    Let's consider a template function written in C++11 which iterates over a container. Please exclude from consideration the range loop syntax because it is not yet supported by the compiler I'm working with. template <typename Container> void DoSomething(const Container& i_container) { // Option #1 for (auto it = std::begin(i_container); it != std::end(i_container); ++it) { // do something with *it } // Option #2 std::for_each(std::begin(i_container), std::end(i_container), [] (typename Container::const_reference element) { // do something with element }); } What are pros/cons of for loop vs std::for_each in terms of: a) performance? (I don't expect any difference) b) readability and maintainability? Here I see many disadvantages of for_each. It wouldn't accept a c-style array while the loop would. The declaration of the lambda formal parameter is so verbose, not possible to use auto there. It is not possible to break out of for_each. In pre- C++11 days arguments against for were a need of specifying the type for the iterator (doesn't hold any more) and an easy possibility of mistyping the loop condition (I've never done such mistake in 10 years). As a conclusion, my thoughts about for_each contradict the common opinion. What am I missing here?

    Read the article

  • GWT 100% height panel with scroll

    - by Andrey
    Hello! Could anyone help me make normal layout in GWT. I need a main panel which: fills all the browser space (100% height); if being collapsed too much shows scroll bars (autoscroll). When I use old layout (RootPanel, VerticalPanel) I have scroll, but can't get 100% height. When I use new layout (RootLayoutPanel, DockLayoutPanel) I get 100% height, but I don't get any scroll. And also I have some troubles in IE. Is there any sample showing how to achieve both goals? Thanks in advance!

    Read the article

  • Migrating VPC images to Hyper-V

    - by user12015
    I have a couple of development Virtual PC images; now I installed Windows Server 2008 + Hyper-V on my main dev laptop and need to migrate those images to Hyper-V. Google only brings steps for some older version of Hyper-V - I dont even see the wizard steps they are talking about. Any help would be highly appreciated! Thanks! - Andrey

    Read the article

  • SQL SERVER – Solution – Generating Zero Without using Any Numbers in T-SQL

    - by pinaldave
    SQL Server MVP and my friend My friend Madhivanan has asked very interesting question on his blog regarding How to Generate Zero without using Any Numbers in T-SQL. He has demonstrated various methods how one can generate Zero. When I posted note regarding how one he has generated Zero without using number in my blog post for Free Online Training, blog readers have come up with few very interesting answers. I really found them very interesting and here I am listing them with due credit. Special mention to Andery.ca as the answer Andery provided is the one, I myself come up with after very first look and that is why I had left the same as hint in the original article. anil try this select count(cast(null as int)) or any false condition select count(*) where ‘a’=’b’ Varinder Sandhu It seems every currency symbol that SQL Server supports. Return the same value as zero i tried some as select € select ¥ select £ Andrey.ca select count(*)-count(*) Vinay Kumar Another way for generate zero. select Ascii(‘Y’)-Ascii(‘Y’) OR select LEN(”) I like Madhivanan’s answer. and it was awesome. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: PostADay, Readers Contribution, SQL, SQL Authority, SQL Puzzle, SQL Query, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >