I want to implement a new hash table with chaining as an array of lists.
Each object in this inter list will be an implementation of a new class that I created (called " search " ).
Can you please help me?
Thanks.
well I managed to do that by myself so thanks anyway.
after I've learned about hash tables in Java last year i thought it's kinda the same (a special object ) but actually it is just as array of list in python.
if someone else have a different way to do that I'd like to hear about it.
Related
We are generating MDX query dynamically. We pass list of Columns ([DimesnionName].[Attribute.Name] format), Rows ([DimesnionName].[Attribute.Name] format) and Filter ([DimesnionName].[Attribute.Name].[Member Name] format) along with other inputs like, cube name, page number, measure etc.
This information is passed to a C# library and then we use lot of 'If' and 'Else' conditions to process this input and generate MDX query as a string. It requires lot of string manipulation.
You can say it has a workflow. After going through each condition, system generates some output. I am wondering if there is a smarter way to design this library.
I want to remove if else conditions.
I want to make it more readable.
I want to make it more manageable
My Question is: Is there any design principle I can use? I can think of using Windows WorkFlow. Please provide your suggestions
I'm actually on here to see if someone has done just that so I don't have to. No luck so far. But off the top of my head what you might want to look at is some form of rules engine that will evaluate the state of target string and add your various criteria.
Now I haven't even started to look into the syntax of MDX. I'm not that far along, but if I wanted to create an engine to create sql queries I'd look at the parts ( simplest case first ) you need list of columns, a table and list of where clauses. So you could have three or maybe just two basic engine classes one that takes a list of strings and (or better yet a list of expressions) and concatenates them ( or evaluates and then concats them ). If target string is empty then targetString = "select "+ x else targetString = ", " + x. Then do something similar with the where expression. You can get considerably more fancy for that building classes that implement the different forms of where expressions and so on. Then ultimately you'd pass your engine something like
MySqlEngine(new[] {"FirstName", "LastName", "GirlFriendsAddress"},
new []{EqualsExpression("FirstName","Brown"), EqualsExpression("LastName",Dynamite")},
"People");
and it would return
"SELECT FirstName, LastName, GirlFriendsAddress From People Where FirstName = \"Brown\" AND LastName = \"Dynamite\""
I would highly recommend using Expressions to evaluate properties on a target model that matches your table. Then you could make MySqlEnigine(...) you wouldn't have to provide to table name because your model could be named the same and you'd use no strings except for target value of the where clauses.
I know this is not the engine you want but I don't know MDX yet so you'll have to use this as an analogy.
Final thoughts DO NOT USE Window Workflow. You will want to kill yourself half way through and if you make it all the way through than there will be developers cursing your name for many years in the future.
Good luck
oh and if you build the please open source it and tell me so I don't have to do it.
Can you "pass" a "parameter" to a view's map function from the query part of a URL? If so, could you show me an example? By, parameter I mean anyway you can access parts of the query string within the map or reduce function.
Thanks in advance.
That's not quite how views works. The view nominates key-value pairs, where the value could be the whole document. You then ask for something where the key is exactly some value or between a range of values. You have to bend your mind around this way of thinking or it won't make sense. The view is independent of parameters, and then it is narrowed down based on the key or startKey/endKey parameters.
I am doing a workflow for a document library. I put a OnWorkflowItemChanged, and I want to get the value of the column which is changed. I use the workflowProperties.Item["name"] and use the afterProperties. But when I use the workflowProperties.Item["column name"], I still got the original value. When I use the afterProperties, it's NULL.
Then I make another workflow that is the same as above for a list. I can use the workflowProperties.Item["column name"] to get the new value in OnWorkflowItemChanged.
Has anyone come across this problem before? Can you give me some help?
The question seems to mix up Item with ExtendedProperties. As to why a difference is seen on a List/Document Lib, it might have something to do with versionining or perhaps the internal serialization is different. Anyway, some of my experience is outline below. I hope it may be of use:
Use the GUID (as a Guid object, not a string) to access the Before / After ExtendedProperties field. Using the Display Name in the ExtendedProperties will not work. The documentation on it is wrong. You can use SPList.Fields to go from Display Name to Column ID (Guid).
I bind all "Before" to MyWhatever_PreviousProperties and all "After" to MyWhatever_Properties, only accessing MyWhatever_[Previous]Properties after the appropriate event(s)).
i'm some newbie in this matter of .net
i'm trying understand this new paradigm
i began with linq for SQl
but i found this library, kind of framework of T4
more specifically: subsonic T4
i think it could be very usefull
but the support docs outside are very scarce
my first intention is use them in the very simple form: a catalog
lets say... Users
so...
how can i use the model generated with subsonic
( using the iactiverecord)
to implement the record-navigational part.,...???!!!
i mean
i want a simple form
to create, delete or modify records
and that is fairy easy
but
what about to move among records ?
i found how to get the first, the last record..
but how can i advance or go back among them???
how can i order the records..?
it seems everytime imust query the table..
its so?
but how can imove among the records i already got?
all of the exmples found are very simple
dont touch the matter and/ or are repetitive everywhere
so.. please
if anybody can help me
or give more references...
i'd thank you a lot
gmo camilo
SubSonic can return a List of your objects if you call ExecuteTypedList or ToList on a query e.g.
List<Product> products = Products.All().ToList();
Once you've got a List then you can move around it in memory. Have a look at the following references to learn more about collections in .net:
System.Collections.Generic Namespace
IEnumerable<(Of <(T>)>) Interface
List<(Of <(T>)>) Class
I'm starting to do some test on SubSonic 3 and I'm missing some stuff.
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
2nd: Same as the above but for the table columns... where are they?
This is very useful mostly when you need to pass those names as string... it you need to refactor your DB we don't need to look through all the code to find where was I using that column!! Once you re-generate the code the compiler tells you!
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
I'm using ActiveRecord btw...
Thanks guys!
Alex
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
In Structs.tt find the following line of code at line 47:
<# foreach(var col in tbl.Columns){#>
Add the following code above it:
public static string TableName { get { return "<#=tbl.Name#>"; } }
Now you'll have a property that returns the name of the table.
2nd: Same as the above but for the table columns... where are they?
In the generated Structs.cs file, this is included in the 3.0.0.3 version
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
If you're using SqlQuery object you can call ExecuteReader on it. Alternatively you can use Linq syntax to generate return custom shaped objects and they'll get mapped automatically.
1st and 2nd: It's not implemented in the default tt-files.
A similiar question:
SubSonic 3 Simple Query Tool
Problem is that's not a correct implementation if you want the 2.x way - the XColumn properties used to be column objects and not string constants, those were found under the Columns struct. So I hope that check-in will not be accepted and that someone will 2.x-ify it correctly.
Anyway as you can see it seems pretty easy to fix it on your own.