How can I convert c#.net Hashtable to LLBLGenPro2.0 object?

Posts   
 
    
sbalaji123
User
Posts: 26
Joined: 13-Oct-2006
# Posted on: 26-Dec-2006 13:42:41   

Hi,

I am using LLBLGenpro2.0 in my web application. My platform is C#.net 2.0,SQL Server 2005,SQL Server reporting service2005,dundas,telerik etc.,

I have created one typed view object in LLBLGenPro 2.0 and this view contains few records. Based on the data I am doing calculations in my business logic layer.

I am storing these values in a Hashtable and returning the Hashtable.

But I want to return as a LLBLGenPro object instead of the Hashtable.

How can I convert c#.net Hashtable to LLBLGenPro2.0 object?

Please anyone suggest to me that how to achieve this?

Thanks in advance, Balaji

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Dec-2006 07:50:52   

How can I convert c#.net Hashtable to LLBLGenPro2.0 object?

Please elaborate more... What LLBLGenPro2.0 object do you mean? What does the hashtable contain? And does it correspond to an Entity?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 27-Dec-2006 09:05:35   

if the hashtable has the fieldnames as keys and the fieldvalues as values:


foreach(DictionaryEntry entry in theHashtable)
{
    theEntity.SetNewFieldValue((string)entry.Key, entry.Value);
}

Frans Bouma | Lead developer LLBLGen Pro
sbalaji123
User
Posts: 26
Joined: 13-Oct-2006
# Posted on: 27-Dec-2006 10:07:55   

I have created DAL.dll using LLBLGENPRO VERSION2.0. I am referring this dal.dll in my web application.

I have created one typedview object in LLBLGenPro and this typedview contains few records.

After creation and adding items to hashtable, it contains: Hashtable[key] = "x1" Hashtable[key1] = "x2" Hashtable[key2] = "x3" Hashtable[key3] = "x4"

which is not related to table.But these values are derived from typedview records.

Need suggestions from anybody as soon as possible..

Thanks in advance, Balaji

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 27-Dec-2006 10:51:24   

Sorry if I sound rude, but did you read any of our replies?

If we don't know anything about your code, we can't possibly give you any suggestions.

Frans Bouma | Lead developer LLBLGen Pro
sbalaji123
User
Posts: 26
Joined: 13-Oct-2006
# Posted on: 27-Dec-2006 12:04:21   

Hi, I have posted my coding here.Please check and tell me the possible ways to implement..

private Hashtable applyingLogicForSpreadOfResultsGetAvgStd(PeerGroupAvgRatiosSdeviationsBmTypedView dt, string ratioType) { try { char[] chrSplit = new char[] { '@' }; Hashtable avgStd = new Hashtable(); double whiteRegionMinus = 0.00d, whiteRegionPlus = 0.00d, yellowRegionMinus = 0.00d, yellowRegionPlus = 0.00d, redRegionPlus = 0.00d, redRegionMinus = 0.00d, pgAvg = 0.00d, pgStdDev = 0.00d; string[] splitStr; string tempstr; if (dt.Rows.Count >= 1) { for (int i = 0; i < dt.Columns.Count; i++) { if (ratioType.ToUpper() == dt.Columns[i].ColumnName.ToUpper().ToString()) { if (dt.Rows[0][i] != DBNull.Value) { tempstr = dt.Rows[0][i].ToString(); splitStr = tempstr.Split(chrSplit); if (splitStr.Length >= 2) { pgAvg = Convert.ToDouble(splitStr[0].ToString()); pgStdDev = Convert.ToDouble(splitStr[1].ToString()); break; } } } } } if (pgAvg != 0.00d && pgStdDev != 0.00d) { whiteRegionPlus = pgAvg + (lowerStdDevLevel * pgStdDev); // 1 Standard Deviation whiteRegionMinus = pgAvg - (lowerStdDevLevel * pgStdDev); // -1 Standard Deviation yellowRegionPlus = pgAvg + (upperStdDevLevel * pgStdDev); // 1.5 Standard Deviation yellowRegionMinus = pgAvg - (upperStdDevLevel * pgStdDev); // -1.5 Standard Deviation redRegionPlus = pgAvg + (moreThan_1_5_Std_Deviation * pgStdDev); // 2.0 Standard Deviation redRegionMinus = pgAvg - (moreThan_1_5_Std_Deviation * pgStdDev); // -2.0 Standard Deviation } avgStd.Add("whiteRegionPlus", whiteRegionPlus); avgStd.Add("whiteRegionMinus", whiteRegionMinus);

            avgStd.Add("yellowRegionPlus", yellowRegionPlus);
            avgStd.Add("yellowRegionMinus", yellowRegionMinus);

            avgStd.Add("redRegionPlus", redRegionPlus);
            avgStd.Add("redRegionMinus", redRegionMinus);
            return (avgStd);
        }
        catch (Exception ex)
        {
            CDMS.COMMON.ExceptionLog.Log.Error(ex.Message, ex);
            throw ex;
        }
    }

Thanks in advance, Balaji

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Dec-2006 15:26:52   

You didn't answer my previous question....to what LLBLGen Pro object you want to copy the hashtable data?

If the data corresponds to an entity fields, use the way that Frans have posted earlier. Otherwise there will be no point to map those data into any other LLBLGen Pro object. They won't be persisted anyway.

So the questions is: Why do you want to copy those data into another object rather than the Hashtable? If we know the answer to this question, we might guide you to a possible solution.

A side note: In LLBLGen Pro, we have 2 types of objects (data carrying objects): 1- Objects for reading and writing data from and to the database -> Entities & their collections 2- Objects for only reading data from the database -> TypedViews, TypedLists & Dynamic Lists