LVOOP technique for passing classes down to subVIs

Hello LVOOP experts,
A quick question regarding performance of LVOOP. I finally got around to implementing something non-trivial with LV classes, just for fun though.
If my architecture consists of a state machine, with a typedef'ed shift-registered cluster (containing all my core classes) being passed around the main loop and into subVIs, is there a performance penalty if the classes contain lots of data?
My question arises from my only passing knowledge of how LV classes work. As they are byvalue, does this mean ALL the data gets copied/moved between every state, and into every subvi? Or is the compiler smart enough to know that if I am passing the main cluster into a subVI it doesn't necessarily need to make a copy of the data unless I am forking it or something.
Fictional example, one of the classes is a data storage and has 1M DBL values in it, is this going to cause lots of memory allocation? (If so then its better probably to not store the data directly in the class, rather have a queue or some other byref storage, right?)
Comments appreciated :-)
n
nrp
CLA

nrp wrote:
Mark Yedinak wrote:
My understanding is that LVOOP objects are passed by value. So you would indeed take a hit if you are passing large objects around.
Thats as much as I suspected, thanks for the confirmation.
My big problem is I have not seen a reference implementation of how to do it right. I sure wish NI would provide some intermediate example rather than dog/cat or car/truck.
The closest I have seen in DfGrays Xylophone set of tutorials, but then he complicates things by using a singleton type approach (dequeue --> use object --> requeue) and a strange (to me) architecture with lots of registered events and an event structure as one of the cases of the main state machine loop.
Does anybody have a non-trivial, but freely distributable example of doing classes the right way? I know there are probably a dozen or so ways of doing it right, but there must be some common ground.
I spent the weekend mucking about and have something which I will present once I have tidied it up a bit.
But the overhead is probably negligible for non-storage type classes, i.e. the classes that define the
HI Mark and Neal (?)
The Pass by value story is starting to shape as a misnomer (sp? bad name).
1) If I do a Show buffer allocations when a class wire splits, the buffer does not show-up under clusters of array but rather as a scalar.
2) You can type cast the class ref as a U32 and you get a number.
3) When using Dynamic Dispatching you have to have the class control and indicator on the icon connector, so all of the requirements are present for the sub-VI (method) to work in-place using the bufer that was pointed to by the caller.
So passing the data in a class is about the same as when working with clusters. If LV can avoid the copy it will.
But where you will take a hit...
When we fork a class wire there is a buffer allocated. Too many splits could cause problems. As long as we string together lines of VLOOP methods, they should use the same buffer.
BTW:
I did have to do a re-write of one of my early LVOOP projects because I was splitting a class with a Image data in it. The re-wire skipped using the class and just passed the image data (via a queue between threads).
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • How can i get a comedy, Dutch Treat or/and its companion Detective School Dropouts released in 1987 be included in the iTunes US store for me to down load. i will pay any thing to download them.

    I wish to request that a comedy, Dutch Treat or/and its companion Detective School Dropouts released in 1987 be included in the iTunes US store for me to down load. i will pay any thing to download them.

    You can try requesting it via this page (these are user-to-user forums) : http://www.apple.com/feedback/itunes.html
    But unless the the US rights-holder passes it to Apple and allows them to sell it in the US then Apple won't be able to sell it there

  • Using a different background for the drop down options in a spry menu bar

    Hi all,
    I am trying to set just a background color in the drop down menu, I have a background image repeated along the x asis at the top but this has come down into the sub menu bar how can I change just the lower drop down menu to just a solid color??
    I have tryed google and youtube to try to find a answer but have had no luck in finding the solution to this problem.

    Give a man a fish, you feed him for a day. Teach a man to fish, he eats every day…
    winabe23, you joined this month—probably because you were having trouble with CSS and HTML and you have certainly come to the right place.
    I'm going to send you to several places I have found helpful in understanding how you can make drop-down menus in CSS without the need for JavaScript—though JS may be necessary for certain older browsers that do not understand pseudo classes and may be necessary for the blind or keyboard navigation.
    CSS Wizardry has a great tutorial here.
    Line25 has one here.
    For those who don't want to have to wrangle code, here is a menu generator from PureCSSMenu.
    Here's a page by Eric Meyer who describes how the concept works.
    And here is a video tutorial by "zorro30mum." It's in two parts, but there is a link to Part 2 below Part 1.
    The reason why I am posting all of these links in my answer is because you're using Spry. And Spry has been found wanting by Adobe and they are deprecating and abandoning it.
    The Spry framework is an open source Ajax framework that Adobe developed. Ajax stands for Asynchronous JavaScript And XML. On August 29th 2012, Adobe handed over Spry to github. If you want to help github develop Spry, there is a site for that, but I'm thinking you're not a JavaScript developer.
    I would recommend you pay a little more attention and time to Ajax, which is not deprecated and not discontinued. It allows you to do client-side triggers for server-side code. But that's if you want to do work in JavaScript, XML and a server-side language, like Cold Fusion, php or ASP.
    But in the meantime, the tutorials above will get you into understanding how this whole menuing stuff is done in CSS and give you the understanding necessary to do simple stuff, like changing the color of a background for a drop-down.
    I hope this helps you make great websites!
    -Mark

  • Not able to created Number Ranges for Asset Classes in AS08

    Dear Friends,
    I am not able create Number Ranges for Asset Classes in AS08.
    It is giving me an error message as company code does not exist.
    When I Check Consistency under path SPRO -> Financial Accounting -> Asset Accounting -> Preparing for Production Startup -> Check Consistency -> Overview Report: Company Codes. I am getting the following
    RSOL  Reliance Sealink One PLtd                                            
    CoCode no. alloc.    NKTR                                                
    Fiscal Year Variant  V3   Apr.- March, 4 special periods                 
    Start 2nd half month 00                                                  
    Transfer date        31.03.2006                                          
    Chart of dep.        TOLL Chart of Depreciation - For Highway Projects   
    Net worth tax        01   Book depreciation as per Compinies Act 1956    
    Enter net book value                                                     
    Status company code  2                                                   
    Current fiscal year  2007                                                
    Doc. type dep. pstng AF   Dep. postings                                  
    > Number range &1 in co.code &2 for doc.type &3 must be defined as internal
    Calc.insur.value                                                         
    Input tax exempt         
    If you see the above first two line you will find the difference is that Company code RSOL in the first line and NKTR company code in the second line.
    Actually CoCode no. alloc. has been wrongly copied as NKTR while copying CoCode it should be RSOL and not NKTR.
    I think because of this wrong allocation it is giving me an error in AS08. Also it is not showing me CoCode in drop down list in AS08.
    Please help me to resolve the problem.
    Thanks
    Rahul Jain

    Look in TC OAOB if the company code is assigned to a chart of depreciation

  • What is the best technique for resetting a view?

    I was wondering what is the best technique for resetting the initial state of a view?
    I am creating a form and want to provide a reset button for the user.  I could write an initialize() method that my action handler calls, but I am wondering if the framework already provides this functionality in a more elegant way.
    If I write an initialize method, then I have to manually populate my fields with my context mappings in my initialize() code to mimic what happens automatically by the framework the first time the view is called.  This seems prone to error since this is duplicating the mapping logic.
    Michael

    Hi,
    Even though it boils down to the same logic, for consistency sake it is good to have the initialization logic coded in the inbound plug method and then to call the outbound plug on reset.This make more sense when you have multiple navigation possible to the same view through multiple inbound plugs.
    Else, have an initialization method.
    PS: check whether the reset() method of IWDContext make sense. This is helpful when you have remove dynamically added nodes and attributes.
    Thanks and Regards,
    Sam Mathew

  • How to search for available class in given package?

    How to search for available class in given package or sub package?

    Finally i did it. I make hibernate and spring without much configuration. I just pass the package pattern to search for all bean. I named it package pattern injection.
    My website is still under construction yet. It named Jimmy6 Framework.
    The code it just the following for all hibernate and spring bean for the whole project.
    <bean id="sessionFactory" class="com.j6.framework.JAnnotationSessionFactoryBean">
              <property name="annotatationOrHbmXmlPackagePattern">
                   <list>
                        <value>com\.j6\.project.+?\.vo\..+?</value>                    
                   </list>
              </property>               
    <bean id="autoBeanCreatorFactoryManager" class="com.j6.framework.resource.AutoBeanCreatorFactory">
              <property name="packagePatterns">
                   <list>
                        <value>com\.j6\.project\..+?\.manager\..+?</value>
                   </list>
              </property>
         </bean>
         <bean id="autoBeanCreatorFactoryDao" class="com.j6.framework.resource.AutoBeanCreatorFactory">
              <property name="packagePatterns">
                   <list>
                        <value>com\.j6\.project\..+?\.dao\.hibernate.+?</value>
                   </list>
              </property>
         </bean>Feel free to have a look and gv some comments. Thanks :)
    Regards,
    Jimmy6
    Edited by: jimmy6 on Nov 4, 2008 8:15 AM

  • Passing Class T to a generic MyClass T 's constructor

    I have a class like this:
    class MyClass<T> {
        Class<T> theClass;
        MyClass(Class<T> theClass) {
            this.theClass = theClass;
    }This would require the following code to instantiate:
    MyClass<String> myClass = new MyClass<String>(String.class);Correct? This is the simplest syntax for creating the class? It seems redundant to have to pass the type "String" twice when constructing the class. I understand constructors can have type parameters like methods, but that type parameter doesn't translate the T parameter to the class, so that won't work.
    I tried the following solution:
    class MyClass<T> {
        Class<T> theClass;
        MyClass(Class<T> theClass) {
            this.theClass = theClass;
        public static MyClass<T> create(Class<T> theClass) {
            return new MyClass<T>(theClass);
    }This allows for the syntax:
    MyClass<String> myClass = MyClass.create(String.class);Which seems more elegant. Of course, the obvious problem with doing this is that it makes subclassing of MyClass much more difficult. Sometimes I can get away with this workaround, more often I cannot. Have I missed anything?

    Let's be real here. We are talking about a single line of code. Not a huge class.
    You have to change the one if you change the other. There's no danger of one
    getting left behind.I don't agree. The nature of creating a class is that for every class you create, there will be one or more (usually more, sometimes MANY more) users of that class. If it were a class like StringBuffer that is used in a million places, then you are making code less redundant for each one of those use cases, and all you had to do was add a factory method.
    You are creating a factory method on you class because of distaste for a
    syntactical construct. You don't see how this factory method changes the
    design?In a strict sense, yes, it impacts the design inasmuch as adding a method changes the contract of the class. However, I don't see how it makes any practical difference in the design.
    Are you going to create this factory method for every class that has this kind of
    situation? I imagine someone is going to come along later to maintain the
    code and think "what the..?" Yeah, and they'll click on "Go to definition" in their IDE and see the extremely complicated method:
    public static <U> create(Class<U> theClass) {
        return new MyClass<U>(theClass);
    }If they can't understand that, they don't understand generic code and probably shouldn't be mucking around there anyway.

  • Passing control reference to subVI crashes labview

    Hi,
    using a image control (as indicator) provided by imaq Vision, I tried to pass the reference of the control to a subVI. On a computer it works and on a other (same labview version, same vision version, same os, same hardware and hardware drivers!), this crashes labview. I tried to close the control refnum at the end of the subVI, but that changed nothing to the issue. Now I use the reference as a global variable and it seems to work...nevertheless, I would like to understand what the issue and if I should remove any passing to subVI of control ref because this can potentially triggers an error. My correlated question is if this global passing is a "fake" workaround or have real chance of improving (this before going through the whole code for changing all passing of reference to subVI)
    thanks a lot

    Hi,
    thank CoastalMaineBird for your answer
    How do you know it's this issue which causes the crash?
    When I remove this parameter from and the only property node in the subVi that write to it, I have no longer any problem. Moreover, to ensure that's really the "passing", and made a global variable containing the reference to this control and use my original SubVi that do access the control through its reference number
    , and it works! In this last exemple, the only change is the way of transmitting the reference
    What LabVIEW version?
    8.0.1
    up to date according Measurement & Automation update tool
    Given that one computer works OK, and another crashes, I would say that
    you are seeing the effect of something else, not the cause. If passing
    a control ref via terminals was fatal, it would be fatal all the time.
    You have some other sort of issue, perhaps timing of the different
    machines triggers the bug, perhaps running out of memory, perhaps
    LabVIEW is corrupted on one machine.... But I don't think changing all
    your code to use globals would solve the real problem. Actually, saying that I wonder about problem of synchronisation. I know from Visual C++ that this kind of error happens if two process try to access the same control at the same time. This is typically an error changing from a computer to an other, and mutex or semaphore are the way to deal nicely with that. But does labview contains already such a securisation? If so, the global variable point on a single object and can "fell" the semaphore/mutex. But passing make a copy that will likely have two different semaphore/mutex but will point to a single control! Do someone know if I'm wrong in this idea or not?
    Thanks

  • Advanced Development Techniques for Oracle Portal Components

    Hello friends,
    I have the following problem. I have a report and a form (on a
    view) in the same page, and when I select an item of the report
    the form is refreshed with the values associated to the selected
    item. The problem is that it makes it with delay, the first
    selection doesn't show anything and the remaining sample the
    data of the previous selection.
    This application has been developed as Ken Atkins explains in
    its document "Advanced Development Techniques for Oracle Portal
    Components."
    Oracle Portal Version: 3.0.9.8.0
    Thanks in advance.
    This is my code:
    -- REPORT --
    SELECT '<A HREF="http://mipc/portal30/
    ALFONSO.refrescar_contenido?
    p_variable=nombre_preferencia&p_variable_valor='||nombre_preferen
    cia||'&p_pagina=61">'||Preferencias||'</A>' nombre_link
    FROM ALFONSO.PREFERENCIAS
    -- PROCEDURE TO REFRESH THE PAGE --
    CREATE OR REPLACE PROCEDURE refrescar_contenido(p_varible IN
    VARCHAR2,
              p_variable_valor IN varchar2,p_pagina IN
    VARCHAR2) IS
    v_Sesion portal30.wwsto_api_session;
    BEGIN
    v_Sesion := portal30.wwsto_api_session.load_session
    ('CONTEXT','SESS_EMP');
    v_Sesion.set_attribute(p_varible, p_variable_valor);
    v_Sesion.save_session;
    owa_util.redirect_url('http://mipc/servlet/page?
    pageid='||ppagina||chr(38)||'_dad=portal30'||chr(38)
    ||'_schema=PORTAL30'||chr(38)||'_mode=3');
    END;
    -- FORM --
    -- ... BEFORE DISPLAYING THE PAGE
    alfonso.consulta_preferencia(p_session);
    -- PROCEDURE consulta_preferencia --
    CREATE OR REPLACE PROCEDURE consulta_preferencia(p_session in
    out PORTAL30.wwa_api_module_session) IS
    v_RowID VARCHAR2(100);
    v_Session portal30.wwsto_api_session;
    v_nombre VARCHAR2(40);
    BEGIN
    v_Session := portal30.wwsto_api_session.load_session
    ('CONTEXT','SESS_EMP');
    v_nombre := v_Session.get_attribute_as_varchar2
    ('nombre_preferencia');
    IF v_nombre IS NOT NULL THEN
    BEGIN
         SELECT rowidtochar(rowid) INTO v_RowID
         FROM ALFONSO.VISTAPREFERENCIAS
         WHERE nombre_preferencia = v_nombre;
    -- VISTAPREFERENCIAS it is the view in which the form is
    based.
    END;
    -- Tell the component that the query is coming from a link,
    and that the rowid
    -- is being used to query the correct context record.
    p_session.set_value (p_block_name=>'DEFAULT',
    p_attribute_name=>'_CALLED_FROM_LINK'
                   ,p_value=>'ROWID');
    -- Pass the rowid of the context record to query.
    p_session.set_value (p_block_name=>'DEFAULT',
    p_attribute_name=> '_ROWID'
                   ,p_value=> v_RowID);
    -- Now do the actual query, using the query button
    processing in the target module
    portal30.wwa_api_module_event.do_event
    ('DEFAULT','QUERY_TOP',1,'ON_CLICK',True,'',p_session);
    -- Save the session information, which includes the
    p_session.save_session;
    END IF;
    END;
    /

    You can make the report with a procedure from which you may call to a form by means of a link. It is a possibility, no??
    It is better a example:
    TABLE A
    campo1 VARCHAR2 (20)
    campo2 VARCHAR2 (20)
    CREATE OR REPLACE PROCEDURE REPORT IS
    v_cursor NUMBER;
    sentencia VARCHAR2(200);
    vnumfilas NUMBER;
    rowid_pref VARCHAR2(18);
    v_campo1 <schemaname>.A.campo1%TYPE;
    v_campo2 <schemaname>.A.campo2%TYPE;
    BEGIN
         htp.p('<HTML>');
         htp.p('<HEAD>');
         htp.p('</HEAD>');
         htp.p('<BODY>');
              sentencia := 'SELECT rowidtochar(rowid), campo1, campo2 FROM A';
              DBMS_SQL.PARSE(v_cursor,sentencia,DBMS_SQL.V7);
              DBMS_SQL.DEFINE_COLUMN(v_cursor,1,rowid_pref,18);
              DBMS_SQL.DEFINE_COLUMN(v_cursor,2,v_campo1,20);
              DBMS_SQL.DEFINE_COLUMN(v_cursor,3,v_campo2,20);
              vnumfilas := DBMS_SQL.EXECUTE(v_cursor);
              LOOP
              IF DBMS_SQL.FETCH_ROWS(v_cursor)=0 THEN
                        EXIT;
              END IF;
              DBMS_SQL.COLUMN_VALUE(v_cursor,1,rowid_pref);
              DBMS_SQL.COLUMN_VALUE(v_cursor,2,v_campo1);
              DBMS_SQL.COLUMN_VALUE(v_cursor,2,campo2);
              v_link := '<A href="PORTAL30.wwa_app_module.link?p_arg_names=_moduleid'||chr(38)||'p_arg_values=<form's moduleid>'||chr(38)||'p_arg_names=_rowid'||chr(38)||'p_arg_values='||rowid_pref||chr(34)||'>'||campo1||'</A> '||campo2||' <BR>';
                   htp.p(v_link);
                END LOOP;
         htp.p('</BODY>');
         htp.p('</HTML>');
    END;
    the form has to be based on the table A.
    I dont know if this example has errors, but have you the idea??
    I hope it helps you out.
    (Excuse my english)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Easy Cost Planning - Passing info down the hierarchy

    Is it possible in Easy Cost Planning to pass characteristics down the hierarchy for use lower down.
    For example, enter the dimensions at the top level and have them passed down for use in calculations lower down the hierarchy?
    Thanks
    Graham

    Here is a WIKI that has detailed steps to create.
    http://wiki.scn.sap.com/wiki/x/5IHpFQ
    http://wiki.scn.sap.com/wiki/display/PLM/ABAP+calls+to+create+Easy+Cost+Planning+in+Project+Systems

  • How to pass class object  as in parameter in call to pl/sql procedure ?

    hi,
    i have to call pl/sql proecedure through java. In pl/sql procedure as "In" parameter i have created "user defined record type" and i am passing class object as "In" parameter in call to pl/sql procedure. but it is giving error.
    so, anyone can please tell me how i can pass class object as "In" parameter in call to pl/sql procedure ?
    its urgent ...
    pls help me...

    793059 wrote:
    I want to pass a cursor to a procedure as IN parameter.You can use the PL/SQL type called sys_refcursor - and open a ref cursor and pass that to the procedure as input parameter.
    Note that the SQL projection of the cursor is unknown at compilation time - and thus cannot be checked. As this checking only happens at run-time, you may get errors attempting to fetch columns from the ref cursor that does not exist in its projection.
    You also need to ask yourself whether this approach is a logical and robust one - it usually is not. The typical cursor processing template in PL/SQL looks as follows:
    begin
      open cursorVariable;
      loop
        fetch cursorVariable bulk collect into bufferVariable limit MAX_ROWS_FETCH;
        for i in 1..bufferVariable.Count
        loop
          MyProcedure( buffer(i) );   --// <-- Pass a row structure to your procedure and not a cursor
        end loop;
        ..etc..
        exit when cursorVariable%not_found;
      end loop;
      close cursorVariable;
    end;

  • What is the procedure/code in VBA for passing the calc scripts dynamically based on the selection.

    Hello Gurus,
    I want to know what is the procedure/code in VBA for passing the calc scripts dynamically based on the selection.
    For example:
    X=EssVCalculate("Sheetname","Calc_Script name",True)
    In the above code instead of the *"Calc_Script name"* I want a script which is called dynamically and the values are calculated accordingly.
    Thanks in advance
    Saurabh

    Hi Todd,
    This is the situation:
    I have a calc script in Essbase which I can call to perform the calculations on the current sheet that is retrieved. I want calculation for the following formulas:
    x = EssVCalculate("Sheet2", "CalcBC", False)
    CalcBC is my calc script which is present in Essbase
    So instead of passing the above script I want to pass the conditions dynamically in the VBA code . I don't want to mention the script name directly in EssVCalculate option
    For example:
    I have three drop down menus from which I would select three different( zero level )members. It would then retrieve the data for that particular values in the excel sheet and now when I click on Calculate button it should calculate the script dynamically.
    I don't know how calc scripts can be executed dynamically in the VBA code itself.
    Thanks in Advance
    Saurabh

  • Can we have more than one contructor for one class?

    I need to provide more than one constructor for one class because I need to have one parameter passed to one constructor and many to another. Is that possible and how it will affects in the instantiation of the object?
    Thanks again
    Jorg3

    One more note about constructors...
    if you define a constructor to take argument(s)
    and don't define the default constructor it is not available.
    Example
    public class myClass
       public static void main(String args[])
          // Ok
          myClass c = new myClass("Hello World");
         // Not Ok
         myClass c2 = new myClass();
       } // main
       public myClass(String name)
          named = name;
       } // myClass
      String named = null;
    } // myClassIf you want to be able to construct the object with the default and parameter constructors, you must declare them all...
    public class myClass
       public static void main(String args[])
          // Ok
          myClass c = new myClass("Hello World");
         // Ok
         myClass c2 = new myClass();
       } // main
       public myClass()
          named = "No Name";
       } // myClass
       public myClass(String name)
          named = name;
       } // myClass
      String named = null;
    } // myClass

  • Generic Data Access For All Class

    Hello
    I am doing one experiment on Data Access. In traditional system We have to write each Insert, Update, Delete code in data access for each table.
    My City Table Class:
    public class TbCitiesModel
    string _result;
    int _cityID;
    int _countryID;
    string _name;
    int _sortOrder;
    bool _enable;
    DateTime _createDate;
    string _countryName;
    public string result
    get { return _result; }
    set { _result = value; }
    public int cityID
    get { return _cityID; }
    set { _cityID = value; }
    public int countryID
    get { return _countryID; }
    set { _countryID = value; }
    public string name
    get { return _name; }
    set { _name = value; }
    public int sortOrder
    get { return _sortOrder; }
    set { _sortOrder = value; }
    public bool enable
    get { return _enable; }
    set { _enable = value; }
    public DateTime createDate
    get { return _createDate; }
    set { _createDate = value; }
    public string countryName
    get { return _countryName; }
    set { _countryName = value; }
    Traditional Code:
    public List<TbCitiesModel> DisplayCities()
    List<TbCitiesModel> lstCities = new List<TbCitiesModel>();
    using (SqlConnection connection = GetDatabaseConnection())
    using (SqlCommand command = new SqlCommand("STCitiesAll", connection))
    command.CommandType = CommandType.StoredProcedure;
    SqlDataReader reader = command.ExecuteReader();
    while (reader.Read())
    lstCities.Add(new TbCitiesModel());
    lstCities[lstCities.Count - 1].cityID = Convert.ToInt32(reader["cityID"]);
    lstCities[lstCities.Count - 1].countryID = Convert.ToInt32(reader["countryID"]);
    lstCities[lstCities.Count - 1].name = Convert.ToString(reader["name"]);
    lstCities[lstCities.Count - 1].sortOrder = Convert.ToInt32(reader["sortOrder"]);
    lstCities[lstCities.Count - 1].enable = Convert.ToBoolean(reader["enable"]);
    lstCities[lstCities.Count - 1].createDate = Convert.ToDateTime(reader["createDate"]);
    return lstCities;
    The above code is used to fetch all Cities in the table. But when There is another table e.g  "TBCountries" I have to write another method to get all countries. So each time almost same code but just table and parameters are changing.
    So decided to work on only one global Method to fetch data from Database.
    Generic Code:
    public List<T> DisplayCitiesT<T>(T TB, string spName)
    var categoryList = new List<T>();
    using (SqlConnection connection = GetDatabaseConnection())
    using (SqlCommand command = new SqlCommand(spName, connection))
    command.CommandType = CommandType.StoredProcedure;
    foreach (var prop in TB.GetType().GetProperties())
    string Key = prop.Name;
    string Value = Convert.ToString(prop.GetValue(TB, null));
    if (!string.IsNullOrEmpty(Value) && Value.Contains(DateTime.MinValue.ToShortDateString()) != true)
    command.Parameters.AddWithValue("@" + Key, prop.GetValue(TB, null));
    SqlDataReader reader = command.ExecuteReader();
    while (reader.Read())
    int i = 0;
    TB = Activator.CreateInstance<T>();
    int colCount = reader.FieldCount;
    foreach (var prop in TB.GetType().GetProperties())
    if (prop.Name != "result" && i <= (colCount - 1))
    prop.SetValue(TB, reader[prop.Name], null);
    i++;
    categoryList.Add(TB);
    return categoryList.ToList();
    Calling method:
    TbCitiesModel c = new TbCitiesModel();
    Program p = new Program();
    List<TbCitiesModel> lstCities = p.DisplayCitiesT<TbCitiesModel>(c,"STCitiesAll");
    foreach (TbCitiesModel item in lstCities)
    Console.WriteLine("ID: {0}, Name: {1}", item.cityID, item.name);
    Now Its working fine but I have tested with 10,00,000 Records in TBCities Table following are the result.
    1. The Traditional method took almost 58 - 59 -  58 - 59 - 59 seconds for 5 time
    2. The Generic Method is took 1.4 - 1.3 - 1.5 - 1.4 - 1.4  [minute.seconds]
    So by the results of test is generic method is probably slower in performance [because its have 3 foreach loops] but the data is very big almost 10,00,000 lakes records. So it might work good in lower records.
    1. So My question is can I used this method for real world applications ?? Or is there any performance optimization for this method?
    2. Also we can use this for the ASP.NET C# projects??
    Owner | Software Developer at NULLPLEX SOFTWARE SOLUTIONS http://nullplex.com

    Hi
    Mayur Lohite,
    Q1:It is not reasonable compared Generic Code with Traditional Code. The main issue not Generic.
    After take a look at your Generic Code.  Reflection code get slower in performance.
    TB = Activator.CreateInstance<T>();
    As Reflection is truly late bound approach to work with your types, the more Types you have for your single assembly the more slow you go on. Basically few people try to work everything based on Reflection. Using reflection unnecessarily will make your application
    very costly.
    Here is a good article about this issue, please take a look.
    Reflection is Slow or Fast? A Practical Demo
    Q2:Or is there any performance optimization for this method?
    The article presents some .NET techniques for using Reflection optimally and efficiently.
    optimizing object creation with reflection
    Note optimize
    reflection with Emit
    method.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.
    Hello Kristin
    Please can you tell how I optimize reflection in my code.
    public List<T> DisplayCitiesT<T>(T TB, string spName)
    var categoryList = new List<T>();
    using (SqlConnection connection = GetDatabaseConnection())
    using (SqlCommand command = new SqlCommand(spName, connection))
    command.CommandType = CommandType.StoredProcedure;
    foreach (var prop in TB.GetType().GetProperties())
    string Key = prop.Name;
    string Value = Convert.ToString(prop.GetValue(TB, null));
    if (!string.IsNullOrEmpty(Value) && Value.Contains(DateTime.MinValue.ToShortDateString()) != true)
    command.Parameters.AddWithValue("@" + Key, prop.GetValue(TB, null));
    SqlDataReader reader = command.ExecuteReader();
    while (reader.Read())
    int i = 0;
    TB = Activator.CreateInstance<T>();
    int colCount = reader.FieldCount;
    foreach (var prop in TB.GetType().GetProperties())
    if (prop.Name != "result" && i <= (colCount - 1))
    prop.SetValue(TB, reader[prop.Name], null);
    i++;
    categoryList.Add(TB);
    return categoryList.ToList();
    Thank you.
    Owner | Software Developer at NULLPLEX SOFTWARE SOLUTIONS http://nullplex.com

  • Support for generic classes

    hi,
    i m using creator 2 update 1, it does not support generic classes.
    it says use source 1.5 for generic classes.
    please tell me how to solve this problem
    thank you

    Well, not necessarily true... Most of the latest graphics cards work off of a common core, which is named depending on its maximum tested performance and on how many pipelines passed quality checks.
    Thus a 7300 is fundementally identical to a 7800, except that it uses fewer fragment/vertex pipelines and is clocked lower. This is done either artificially by disabling parts of the GPU, or if when they fail quality control.
    Either way, the drivers are the same, and have been unified for a long time for the entire product line. In fact if you look at the drivers for the card in yoru computer you will see they are more then likely for a different chipset. My MBP claims the drivers are for a X1000, even though the card is a X1600.

Maybe you are looking for

  • Acrobat won't save any more links in a PDF. Why?

    I am adding links to a PDF file. I have done several, including the index of the file. Acrobat won't save any more though. Why?

  • Converting RGB to CMYK - Huge color shift. Any tips on getting some decent color back?

    I just downloaded a St. Patricks day background from iStockPhoto. Nice vibrant green. We all know when converting to CMYK from RGB, there is a color shift but this is pretty dang dramatic. Any basic tips on getting some of that vibrant color back aft

  • Framing error on seriell port

    Hi, I am trying to read data from the seriell port. I doesn't know exactly the correct setting for communication with the external device, but I know, I use the correct baud rate. My problem is, I get from the "Bytes atseriell port.vi" the error 4008

  • Fireworks CS6 Trial cannot connect when I try to sign in.

    I've recently downloaded the Fireworks CS6 trial. I get the screen that promts me to sign in with my Adobe ID. Once I click the Sign In button I get the loading animation amd after a moment it will tell me to "Please connect to the Internet and retry

  • I cannot pay for extending my licences...

    Hi, I own a E51 on which I installed OVI maps 3.01. After installation, I bought a licence for one month for driving in Europe; I paid through my telephone bill. I want now to renew this licence for one year; I CANNOT: If I use my credit card, nothin