Tuesday, 15 July 2014

asp.net mvc 3 - Linq Grouping looses the child entities -


मेरे पास निम्न प्रश्न हैं:

  var _customers = (c से _db.UserProfiles । (X = & gt; x.ParentCompanies) को शामिल करें। (X = & gt; x.cprofile) शामिल करें। (X = & gt; x.cprofile.PhoneNumbers) को शामिल करें। (X = & gt; x.cprofile.Addresses) में शामिल करें C.ParentCompanies.Any (pc = & gt; pc.CompanyUsers.Any (cu = & gt; cu.UserName == उपयोगकर्ता नाम)) & amp; amp; c.cprofile! = नल) समूह c द्वारा c.FirstName.Substring (0, 1)। ग्राहक में समूह के ऊपर () को नए संपर्क दृश्यमॉडल का चयन करें {प्रथमलेटर = ग्राहक समूह.केय, ग्राहक = ग्राहक समूह})। क्रमबी (पत्र = & gt; पत्र। फर्स्ट लाटर);   

अगर मैं समूह को निकालता हूं, तो यह अच्छी तरह से काम करता है और सभी बच्चों को शामिल करता है (parentCompanies, cProfile, ...) के रूप में जैसे ही मैं समूह को वापस रखता हूँ, वह सभी बच्चों को खो देता है मैं इस मुद्दे को कैसे हल करता हूं?

अपडेट

मुझे लगता है कि मैं उस दृश्य मॉडल को भी शामिल कराना चाहूंगा जिसका परिणाम मुझे निकाल देना है। / P>

  सार्वजनिक वर्ग संपर्क ViewModel {सार्वजनिक स्ट्रिंग प्रथम लेटर {प्राप्त करें; सेट; } सार्वजनिक IEnumerable & lt; UserProfile & gt; ग्राहक {प्राप्त; सेट; }}}    

शामिल करें केवल क्वेरी परिणामों में आइटम पर लागू होता है (अंतिम प्रक्षेपण अर्थात) और उस परिचालन को शामिल नहीं कर सकता जो कि शामिल करें और बाहरीतम ऑपरेशन (जैसे समूहबय ()) के बीच परिणाम के प्रकार को बदलते हैं

यदि आप उत्सुक लोड करना चाहते हैं, तो समूह क्लाइंट-साइड करें (यानी क्वेरी की गणना करें तो परिणाम पर समूहबीआई विधि को कॉल करें)

c++ - A Base class technique for exception handling -


का उद्देश्य सी ++ में एक अपवाद-तटस्थ जेनेरिक स्टैक डेटा संरचना को लागू करना है, केवल टेम्पलेट तर्क डिस्ट्रिक्टर मानते ही नहीं फेंकना। यह चाल संभावित रूप से टेम्पलेट तर्क संचालन (कन्स्ट्रक्टर, कॉपी कन्स्ट्रक्टर, असाइनमेंट) फेंकने के लिए संभाल करने के लिए एक संगत स्थिति में ढेर को छोड़ने के लिए संभालना है।

समाधान में, हर्ब सटर का कहना है

इस समाधान को सरल रखने के लिए, मैंने अपवाद-सुरक्षित संसाधन स्वामित्व के लिए बेस क्लास तकनीक का प्रदर्शन नहीं करने का निर्णय लिया है।

कुछ googling के बाद, मैं डेव द्वारा पाया इब्राहीम 1 99 7 से डेटिंग करते हैं। अपने समाधान में वह बेस क्लास में स्मृति के आवंटन और हटाने का संचालन करता है, और उपवर्ग में स्टैक ऑपरेशन को लागू करता है। इस तरह, वह यह सुनिश्चित करता है कि प्रतिलिपि निर्माता में प्रतिलिपि को कॉपी स्मृति आवंटन से अलग किया जाता है, इसलिए यदि प्रतिलिपि विफल हो जाती है, तो आधार वर्ग नाशक कहा जाता है, कोई बात नहीं।

संदर्भ के लिए, यहां डेव की प्रतिलिपि है मेरी टिप्पणी के साथ कन्स्ट्रक्टर ने कहा:

  // v_ स्टैक तत्वों को भंडारित आंतरिक सरणी को संदर्भित करता है स्टैक (कॉन्स्ट स्टैक & amp; rhs): स्टैकबेज & lt; T & gt; (rhsCount ()) // कन्स्ट्रक्टर पर्याप्त स्थान आवंटित करता है / डिस्ट्रक्टर कॉल को [] उचित रूप से हटाना {जबकि (गणना () & lt; rhs.Count ()) पुश (rhs.v_ [गणना ()]);   

यदि बेस कन्स्ट्रक्टर सफल होता है, तो बेस डिस्ट्रिक्ट में मेमोरी क्लीन अप की गारंटी होती है, भले ही उप-वर्ग की प्रतिलिपि कन्स्ट्रक्टर फेंकता हो।

मेरे प्रश्न हैं :

  1. क्या इस दृष्टिकोण के लिए कोई अन्य लाभ है, जैसा कि ऊपर उल्लिखित है?
  2. जब मैं इस समस्या का हल मेरे स्वयं: <पूर्व> // v_ स्टैक तत्वों को भंडारित आंतरिक सरणी से संदर्भित करता है / बनाम__ v_ // vused_ में आवंटित स्थान की मात्रा है v_ stack में अब तक उपयोग की जाने वाली जगह की मात्रा ( Const स्टैक & amp; rhs): vsize_ (0), vused_ (0), v_ (0) {ढेर temp (rhs.vused_); // कन्स्ट्रक्टर कॉल्स `नई टी [num_elements]` `डिस्ट्रक्टर्स कॉल` को हटाएं [] v_` std :: copy (rhs.v_, rhs.v_ + rhs.vused_, temp.v_); // स्वैप (अस्थायी) फेंक सकता है; } शून्य स्वैप (स्टैक & amp; आरए) {std :: swap (v_, rhs.v_); Std :: swap (vused_, rhs.vused_); Std :: swap (vsize_, rhs.vsize_); }

    इस दृष्टिकोण के मुकाबले मुझे बेस क्लास के लिए कुछ मुश्किलें हैं I क्या कोई कारण है कि इस टेम्प्-कॉपी-टू-स्वैप दृष्टिकोण से बेस-क्लास तकनीक को प्राथमिकता दी जानी चाहिए? ध्यान दें कि डेव और मेरे पास पहले से ही स्वैप () सदस्य है क्योंकि हम इसे अपने ऑपरेटर = ()

  3. डेव इब्राहीम की तकनीक बहुत अच्छी तरह से प्रतीत नहीं होती है (Google के अनुसार)। क्या इसका एक अलग नाम है, क्या यह मानक अभ्यास है, क्या मैंने कुछ याद किया है?

    नोट:

    • डेव का पुश () मानें एक लूप में std :: copy
    • के उपयोग के बराबर होने के लिए चलो स्मार्ट पॉइंटर्स को उत्तर से बाहर रख दें, क्योंकि उनका उपयोग स्मृति को प्रबंधित करने की स्थिति को दूर करेगा स्पष्ट रूप से इस अभ्यास में

      व्यवहारिक रूप से दो कार्यान्वयन समान हैं। वे दोनों एक प्रबंधित स्मृति आवंटन ऑब्जेक्ट सेटअप करते हैं जो गुंजाइश पर बाहर निकलने पर साफ़ होगा यदि कन्स्ट्रक्टर विफल रहता है। एक अस्थायी चर में कॉपी करना अधिक महंगा हो सकता है, लेकिन जैसा कि टिप्पणियों में लिखा गया है, std :: move शायद इस तरह की अतिरिक्त लागत को समाप्त कर देगा आपके विशिष्ट प्रश्नों के उत्तर में:

      1. इब्राहीम का उदाहरण आपके वास्तविक वर्ग के कार्यान्वयन विवरणों से ढेर आबंटन को आगे बढ़ाता है। आपके कोड में, अगर आप अपने सरणी की प्रतिलिपि करने से पहले / बाद में अधिक जटिल मेमोरी हेरफेर करते हैं तो सभी संस्थाओं के सही प्रबंधन को सुनिश्चित करना थोड़ा अधिक कठिन हो सकता है। अन्यथा मुझे पहले विवरण के व्यवहार के संबंध में स्पष्ट रूप से कोई स्पष्ट विवरण दिखाई नहीं देता है।
      2. इब्राहीम के कार्यान्वयन को एक ही स्थान के लिए साफ़ किया गया है। यदि एकाधिक वर्ग स्टैकबेज & lt; T & gt; का उपयोग करते हैं, तो वे प्रत्येक को सुरक्षित रूप से अपनी गतिशील मेमोरी मान सकते हैं यदि वे अपवाद फेंक देते हैं अपने कार्यान्वयन में आपको इसे प्राप्त करने के लिए अस्थायी ऑब्जेक्ट और स्वैप कोड को फिर से लिखना होगा (कम से कम भागों) प्रभावी रूप से, यह कार्यान्वयन स्टैकबेज के कई उप-वर्गों को लागू करने के लिए लाइनों की संख्या कम करता है। हालांकि, यदि आप कुछ अन्य बेस क्लास के शीर्ष पर अतिरिक्त मेमोरी आवंटन चाहते हैं, तो आपके कार्यान्वयन में कई विरासत से बचा जाता है। आपका कोड टेम्पलेट कोड ब्लोइंग को समय / आकार संकलित करने से बचा जाता है - हालांकि मैं आम तौर पर इसे अधिकांश मामलों में बड़े नकारात्मक होने पर विचार नहीं करता है। मैं शायद आपके कोड के करीब कुछ को डिफ़ॉल्ट के रूप में इस्तेमाल करूंगा जब तक कि मैं बहुत सामान्य उपयोग केस कोड लिखने की कोशिश नहीं कर रहा था।
      3. मुझे नहीं पता कि इस दृष्टिकोण का कोई विशिष्ट नाम है - मैं इसे अपडेट करूँगा अगर मुझे एक मिल जाए - लेकिन मैंने इसे कम से कम एक सी ++ प्रोग्रामिंग पुस्तक में पहले देखा है।

file - Open the "open"-dialogbox from cmd -


I want to know that I can open "Open" - Dialog box from CMD, so I can use it to open Right file for (I already know how to open files directly from CMD, but not those who are interested in it)

Currently I am doing a project where I have a program (like program .XA). This program needs a model (eg modelfile.mod) I execute in CMD by writing the program: program.exe modelfile.mod, and it works. I have several models with different names, but the program file always has the same name. Every time I need to perform the program in CMD, I would like to make a batch, where I can select the modf which I would like to execute, after which it will run the program with the modf selected as the input .

So I need to know how to open the "open" dialog box from CMD, and how to get the name of the file selected for use in the execution of the program.

  @echo off setlocal set ps_cmd = powershell "class = "Post-lesson" itemprop = "text"> 

Add-Type -AssemblyName System.windows.forms | Out-Null; $ f = New Object System.window.form.openfileDialoghood; $ f.Filter = 'Model Files (* .mod) | * .mod | All Files (*. *) * *. * '; $ F.showHelp = $ true; $ f.ShowDialog () | Out-null; $ f.FileName "for / F "delims =" In %% I ('% ps_cmd%') set the defined filename = "%% I" if you defined the filename (the echo you chose% filename%) Other ( You choose not Skvet!) Goto: EOF

or if you want to break the powers Elseedilets for easy maintenance:

  @echo off setlocal set "Ps = add-type -AssemblyName System.windows.forms | out-null;" set "ps =% ps% $ f = new object system. Windows.form.openfile dialog;" set "ps =% ps% $ f .Filter = 'Model Files (* .mod) | *. Mod | All Files (*. *) | *. *'; "Set" ps =% ps% $ f.showHelp = $ true; "Set" ps =% ps% $ f.ShowDialog () | Out-null; "Set" ps =% ps% $ f.FileName "for / f" delims = "%% I ( 'powershell'% ps% '') in" filename = %% I "set that defines the file name (echo you % have chosen filename%) other (echo you chose not Skvet!) goto: EOF   

set see the documentation for cruelly taken.) other properties written (PowerShell commands, like Title and Initial Directory .

methods - Repeated tasks - spawn new processes or run continuously? -


We have around 10 different Python scripts that download data from the Web, read the data from the database and that database Back in the data write in They do it repeatedly every 10 seconds (or 10 seconds after completion of the final work).

The question is, what is the best way to run these tasks? I can think of some ways:

  1. There is some time that runs the work then sleeps for the interval. It can be carefully guarded like a supervisor, to ensure that it is always there.

  2. By executing the script only once, and once every 10 seconds, another process.

  3. Ask for a script run for 1 hour (every 10 seconds for one hour), and on keeping a watchdog, make sure the job runs once again. .

    I would like to avoid long-running procedures which actually do something because I do not want to work in memory over a long period of time.

    Additional information

    1. The scripts are different because they retrieve data from each different source, and queries, Calculate and separate data in the database.

    2. The work is done every 10 seconds, because the data is being retrieved in real-time, and we should not only update it continuously, but also keep it All historical data in the database

    3. There are lots of resources being used by scripts - MySQL connections, HTTP connections, readies connections, etc. In particular, using the first long-standing approach, we have encountered problems, MySQL connections (things like MySQL servers have gone, although all connections were closed). Therefore, leaning toward scripts to run in less time.

      What are some common approaches to this?

      Unless your script is in some way memory leak (not quite likely), they should all be identical. Therefore, for quite ease ( your time programming / debugging time is more expensive than some milliseconds at the time of machine, even every 10 seconds!) I go to a script which Checks every 10 seconds.

      OTOH looks like busy work in every 10 seconds, can not you set up so that whatever you are monitoring tells you when changes happen? Or batch records so that you can get a day's worth, can you?

c# - Passing object to a WebMethod through jquery ajax -


I am trying to pass an object defined to any page method. I'm trying to pass data to collect it from three text boxes. [System.Web.Services.WebMethod] Public Fixed String saveDataToServer (Object CSobage) {// Function Body} {/ P>

Page Method / Code>

JavaScript / jQuery

  $ ("# osmSendMsg"). Click (function () {debugger; var cntDetails ({# CntName: $ ("# osmContactName", "wait", "/ ContactUs.aspx / saveDataToServer", "csObj");});   

PostDataToServer

  // Post data to server (AJAX call). Function PostDataSource (DataTaused, Stormat Gateto Show, StormTyocol, JasonObjectName) { Debugger; / * Includes JSON object in datacentend SubmitType 1 == Submit normal; 2 == Submit and print Strmessageto Show the text that you please wait In the window. * / Var tempurl = strMethodToCall; var tempdata; $ .ajax ({url: tempurl, type: "post", async: false, data type: "jason", data: "{" + json object name +: "+ JSON.stringify (dataToSend) +"} ", // Timeout: 30000, Content Type:" Application / Jason; Charset = UTF-8 ", Success: Function (Data) {tempdata = data;}, Error: Task (result) {tempdata = null;}}; // Ajax call return end of tempdata;} // closing of post data   

is now reaching the call web method. no problem. I am getting an object too. But how do I process the object?

Inside the data

As you can see, The same is what I am getting, I also tried to declare a class and pass it as a parameter .. but all its assets are empty. If you see that the data is visible as a key, then the value pair. I can convert it to a dictionary, but I believe it is a complex solution.

key - value added

A simple solution was welcomed Will go!

Please find the appropriate way to do this, you too can do it.

reporting services - Type Problems with Filter Expression in SSRS -


SQL Server 2008 R2 is using the bid to design the report.

I have a table and I'm just trying to show a certain line that there are better ways to do this, but I am coming across an error with the expression of the filter And how do I get my initial work done, I want to understand the filtering

I used to type the filter expression ("integer" to be typed):

  line number (none) = 1   < P> This error returned:  
  type can not compare system data. String and system. IN 32 I got a solution of it, from 1 to "= 1" has been evaluated as a string to replace 1.  

So I did it:

  Row number (nothing) == 1   

This has not changed anything I have tried the same thing in the first part of the expression:

  = line number (nothing) = = 1  < / Pre> 

It changed the problem of a deployment (still makes, which is disappointing):

  error pvInvalidDefinition: definition of report '/ ReportName' is invalid   

I then subscribed CIN to Roenambar Tried to sum: CINT (Ronamembar (none) = = 1

Then I can apply it, but the error only changes first one:

  Data type can not be compared to system.String and System.Int32.   

No matter what I try here I can not either report or report to me I get an error that I am comparing a string to an int.

royn number one east Coax, so it seems that it should work. I have tried to use the name of the dataset in place "nothing" but this does not change what I see.

I know there are several ways to solve my initial problem, but I am curious why the filter expression is invalid.

"post-text" itemprop = "text">

It is better to hide a line with visibilty property. Just click on a text box and visit visibily tab. Now let's go to the expression by clicking on Show or Hands.

Hide this default Then type an expression there to hide the row. = IIf (no (line number = 1), TRUE, FALSE)

Let me know if you have any error

c++ - Cartesian product of several vectors -


Similar questions have been asked before but I can not find an exact match for my question.

I have 4 vectors, each of which contains 200-500 4 digits integer. The exact number of elements in each vector varies, but I can fix it for a specific value. I need to find all possible combinations of elements in these 4 vectors.

Example:

v1 [10, 30] v2 [11, 45] v3 [63, 56] v4 [82, 9 8]

Something like this will happen:

[10, 11, 63, 82]; [30, 11, 63, 82]; [10, 45, 63, 82]; [10, 45, 56, 82] etc.

Is there a common name for this algorithm, so can I get its online reference? Otherwise any suggestions for implementing it in C ++ would be useful. Performance is not more of a problem because I need to run the algorithm only once, is anything made in STL?

not much of the algorithm ... <(vector & lt; int & gt; :: constiiterator for i2 = v2.begin (vector & lt; int & gt; :: const_iterator i1 = v1.begin (); i1! = V1.end (); ++ i1);); I2! = V2.end (); ++ i2) for vector const_iterator i3 = v3.begin (); i3! = V3.end (); ++ i3) (vector & lt; int & gt; :: const_iterator i4 = v4.begin (); i4! = V4.end (); ++ i4) COAT & lt; & Lt; "[" & Lt; & Lt; * I1 & lt; & Lt; "," & Lt; & Lt; * I2 & lt; & Lt; "," & Lt; & Lt; * I3 & lt; & Lt; "," & Lt; & Lt; * I4 & lt; & Lt; "]" & Lt; & Lt; Endl;