Marius Gheorghe

public class Developer : TableMetadata

<January 2009>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567


Navigation

Links

Subscriptions

Post Categories



.NET (RSS)

.NET
Karmencita 0.6 released

I have finally released the latest version.  Karmencita is a high level object query language for .NET . It's purpose is to allow easy querying from in memory structured data.

Features :

- easy, SQL like language.

- common, slim API used for querying data.

- supports any IEnumerable data source, DataTables and XmlDataDocuments.

- extensible implementation

- common API but still get results depending on the data source. (for instance when querying XmlDataDocuments we get back XmlElement[]. But if we query a DataTable we get back a DataRow[]).

- supports IComparable for custom type implementation.

Samples :

-query a generic list of Customers :

//get a list of customers
List<Customer> list = ………

ObjectQuery<Customer> oq = new ObjectQuery<Customer>();

string query = “Name=[Marius Gheorghe] and IsMale=true and Age > 10”;

Customer[] custom = (Customer[]) oq.Select(list, query);

 

 - query a DataTable (the Northwind database products table)

//load the DataTable from the database
DataTable dt = ………

ObjectQuery<DataTable> oq = new ObjectQuery<DataTable>();

string query = “Name=[Salted Pork Meat] and Discontinued = false and UnitPrice > 12”;

DataRow[] rows = (DataRow[]) oq.Select(dt, query);

- query a XmlDataDocument

//load the XmlDataDocument
XmlDataDocument dt = ………

ObjectQuery<XmlDataDocument> oq = new ObjectQuery<XmlDataDocument>();

string query = “Name=[Salted Pork Meat] and Discontinued = false and UnitPrice > 12”;

XmlElement[] rows = (XmlElement[]) oq.Select(dt, query);

 

The web site is located at www.voidsoft.ro/karmencita.html

This is free software (LGPL). 

posted Thursday, March 23, 2006 6:58 AM by Gheorghe Marius with 0 Comments

Karmencita - a object query language for DataBlock

Karmencita is a object query language for DataBlock (and in the future it will also support POCO, DataTables and XMLDocuments) which allows us to query "in memory" data structures. It has a simple and straighforward SQL like syntax . Here is a small snippet :

Let's say we have a entity like this

public class Author : TableMetadata

{

  public int AuthorId;

  public string Name;

  public DateTime DateOfBirth;

  public bool Manager;

  public decimal Salary;

}

We retrieve it from database with DataBlock;

Author[] authors =  perst.GetTableMetadata();

and now we can manipulate it with Karmencita :

ObjectQuery<Author> oq = new ObjectQuery<Author>(); // notice that ObjectQuery is a generic class

Author[] selectedData =  oq.Select(authors, " AuthorId > 67 and Name like Stan* and Manager = true");

We can also have math operations on data;

decimal totalSalary = oq.Sum(authors, " Manager = true and AuthorID > 60);

More details (also some bits about implementation) are available in the following paper : www.voidsoft.ro/downloads/karmencita.pdf

Karmecita will be available in DataBlock v1.3 in the October 2005 timeframe.

 

PS: The "Write a review and get a DataBlock license for free" contest is still available.

posted Wednesday, September 07, 2005 1:48 PM by Gheorghe Marius with 0 Comments

DataBlock v1.2 released. Only for .NET 2.0
I'm very happy to announce the release of the DataBlock v1.2. Here is the press release :
" voidsoft is pleased to announce the release of DataBlock v1.2 for
Microsoft .NET 2.0. DataBlock is an advanced O/RM and persistence
framework for .NET 2.0 which helps you  build advanced database
applications fast and easily by generating a complete business facade
for your database entities.  DataBlock comes with DataBlock Modeler (a
GUI tool) which allows you to generate your entities in a few seconds
(it supports both C# and
VB.NET).


Features list : http://www.voidsoft.ro/DataBlock/features.htm
Support Forum : http://www.voidsoft.ro/forum/
Download : http://www.voidsoft.ro/DataBlock/download.htm "
 
Please note that the evaluation version is not limited in any way so give it a shot.
If you have questions you can leave messages on this blog, post on the forum (see link above) 
or mail me directly at gmarius at gmail dot com. Also note that this new release is .NET 2.0 only
so if you're looking for a .NET 2.0 O/RM.....We scrapped the 1.x version and went straight for .NET
2.0 and this is the result of many months of work. We also included a small ASP.NET 2.0 demo
application. Check how you can have ther business facade ready in 15 seconds and how an
application can run on 3 different RDBMS (Access, MySql and SqlServer) only by changing 2
lines in a config file.
A demo video should be up on the site in the following week.
  
PS: I kept my word. End of august :)
 
 
 
 
 

posted Sunday, August 28, 2005 11:36 AM by Gheorghe Marius with 0 Comments

DataBlock news

Work on Datablock ( http://www.voidsoft.ro) continues at a franctic pace. The upcoming release (1.2) will be available at the end of august.
Along with the enhancements (i will talk another time about this) and bug fixes a big noteworthy change :
-.NET 2.0 only.  Mostly for generics (like i already said i'm not entirely happy with the constraints in .NET 2.0 generics) but getting rid of the custom collections along with StringCollections and the like worth it. It's speedier too when compared with 1.1. As long as i'm on this topic....we decided that arrays will still the primary method of returning multiple data ( we can also returned List<TableMetadata> as a conventional sided API for the languages that will support generics......although the generics are CLR compliant i don't expect that most languages will have support for them in the foreseeable future).

  Other new related to DataBlock....well DataBlock will be "the main pillar" of the upcoming codenamed Sunrise business application framework which we will launch along with the .NET 2.0 release. More news about this in the upcoming months.
   We're planning to write some medium size application (with GUI both Windows Forms and ASP.NET) as demonstration for DataBlock.
 (the current one is too small). I will also record a demonstration video for DataBlock  (not everyone has time to read docs ).
 
 So much things to do....so little time. Got to get back to work.

posted Wednesday, July 13, 2005 4:07 AM by Gheorghe Marius with 0 Comments

Stack and Queue don't have indexers.

WHY ?  

Also i just noticed that the Deque<T> class from the PowerCollection has and indexer.

posted Sunday, July 03, 2005 4:17 AM by Gheorghe Marius with 0 Comments

Customizing the CLR

   Finished reading the book. It was a good read. Not really useful stuff for a "managed only" developer.
Actually you would love this if you have to write a "customized" CLR host. It's really interesting
how much work went into the CLR so it can be hosted inside SqlServer.
   My gripe is related to the customization of the CLR using the config file. We can't, for instance,
even customize the size of the thread pool. I'm not expecting to have custom task schedulers for CLR
using the config file but a little more controls over the CLR world be very appreciated. Anyway, for now,
if you want the good stuff you must write a CLR host.
  So the book is pretty good and well written. Recommanded.
 

 

posted Thursday, June 23, 2005 8:25 AM by Gheorghe Marius with 0 Comments

ClickOnce - death of ASP.NET applications ?

   At least ASP.NET applications for the intranet. I confess that i worked
on both Windows Forms and ASP.NET apps. As a user(and also as a programmer)
i prefer the first ones.The usability of the ASP.NET gives a lot to be desired.
The are slow and cluncky.I would choose a normal Windows Application over the
ASP.NET equivalent in a instant.
  In the intranet scenarios the only advantage of the ASP.NET apps is the deployment.
Deploy on server and forget about it. Update on server and everyone has the latest version.
Not so with Windows apps. It looks like ClickOnce is set to change some of that. I am
saying "some" because i'm not sure that ClickOnce will work in complex deploying
scenarios (for instance installing COM+ applications, adding assemblies to GAC etc).
The only demonstrations for ClickOnce i've seen were some "dinky single window form
app" on Channel9. Btw MS guys, when you do demos, it will give you a WAY better credibility
if you demo with more "Real life" apps instead of toys.
  So, it seems that with .NET 2.0, we will be able to deploy/update Windows Forms apps as
easy/fast as ASP.NET. Will this be the death of ASP.NET apps for intranet ?

I certainly hope so.


 

posted Tuesday, June 21, 2005 1:39 AM by Gheorghe Marius with 0 Comments

C# 2.0 dislikes

Some dislikes on C# 2.0 :

- no support for operator constraints in generics.
  This is pretty bad from my point of view. In one of my project i have quite
a few structs which have the primary operators(+, -, *, /) overloaded. Unfortunately
i CAN'T write generic code for these using the operators because there is no way to
add operator constraints.

- Nullable types implementation suck.
   The implementation is NOT clean. It shoudn't be a difference in syntax between
a nullable int and a regular int. No NullableType<int> thingie. Writing "generic" code which
works with both int and int? is hard because you always have to check for the nullable
or you have the use the butt ugly "??" operator.
  A conversion to the default value (in case of int is 0) should be done automatically.
We should not need the "??" operator for that.  The whole ideea of a nullable type is to
check his "nullability" ONLY when i need. I shouldn't be force to "??"it so i can use it
as a regular type. 

posted Thursday, June 16, 2005 7:21 AM by Gheorghe Marius with 0 Comments

No IsNullableType ?
Did some reflection work the other day and i noticed that Type does not have a way to see if the type is nullable or not. The workaround seems to be to GetInterfaces() and check for INullableValue yourself. But still....why not include this in Type ?

posted Wednesday, May 25, 2005 9:26 AM by Gheorghe Marius with 0 Comments

MCAD
Got 70-315 last week so now i'm a Microsoft Certified Application Developer for .NET. But i still think the exams are too easy.

posted Tuesday, May 10, 2005 5:12 AM by Gheorghe Marius with 2 Comments

Mapping objects

There are 2 ways to map objects to  database schemas:

 1. normal classes. These are classes who don't have
a super class (besides System.Object). The mapping is held externally
in a single xml config file (or you can have a single file for each database table schema).
   They can look like this

public class Person
{

   public int Id
   {
     //get-set 
   } 
    
   public string Name
   {
     //get-set 
   }
}  


  The advantage of this model is that you have the "clean" model. No methods, no nothing....just the
clean model. The disadvantages are :

- external dependencies (the xml mapping file(s)).
- informations about the mapped object are found in external classes. This usually creates
a cumbersome API. For instance if you want to now if the Name is null you'll have something like

//check for null.
 IsNull(p, "Name");

- fool around with xml files to update the changes in the database schema.
- the overhead of the mapping information. Usually the mapping info is read when needed
and cached for subsequent needs. The mappinf indo for a single table is not much but when
you cache the mapping information for 100 tables the situation changes.


 2. The mapping is done "in code" and the class inherits from a super class.
This is the approach i have taken with DataBlock. You have a super class (called TableMetadata)
and all the mapped classes inherit from it

public class Person : TableMetadata
{
    //generated implementation 
}

The advantages of this model are :

- you don't write anything. You don't fool around with xml files and you don't write
the class definition. Everthing is generated for you based on the database schema. It's
a few seconds process.
- no external dependencies. Everything compiles into an assembly.
- no overhead of mapping information. Because the mapping info is "in code" the code just runs.
No need to read (and cache) at runtime the mapping info from the xml file.
- information is part of the mapped object. You don't pass an instance of the object
to an "external" API. Taking the above example....if you want to know if a certain field
has a null value :

p.IsNull("Name");

or by index

p.IsNull[1];

  This is both an advantage and the only disadvantage that the model has.
It's a disadvantage because the "mapped object" is not clean anymore. Besides the mapping
object information you also have methods to "query" the mapped objects for informations.
  But the adavantage of beeing much faster (direct calls vs xml reading + reflection) clearly
overweights the disadvantage.
   

posted Wednesday, March 16, 2005 12:19 AM by Gheorghe Marius with 0 Comments

Writing (object oriented) queries

   Any OR/M tool which abstracts multiple RDBMS needs a "RDBMS neutral language" which allows
the programmers to express queries. When i started thinking about this in
DataBlock one of my first thoughts was : I'll implement OQL for DataBlock.
   Except there is a slight problem with OQL......nobody seem to give a rat's
ass about it. The "regular" .NET programmer doesn't even know what OQL is.
So i had to skip OQL (for now....if there are enought request i might add support for OQL) 
and i had implemented an OO way to express queries in DataBlock.It looks like this :

Product prod = new Product();  //the mapped object.
QueryCriteria qc = new QueryCriteria(prod);  //query criteria

The above will select all the fields from the Product table. To select partial
fields you can use:

QueryCriteria qc = new QueryCriteria(prod.TableName, prod.TableFields[0],prod.TableFields[1]);

Adding criterias to the query is simple :

qc.Add(CriteriaOperator.Smaller, prod.TableFields[0], 36);
qc.Add(CriteriaOperator.Higher, prod.GetField("SupplierId"), 50);
qc.Add(CriteriaOperator.Like, prod.TableFields[1], "Chai");

The query criteria above "translates" into the following SQL:

SELECT Products.ProductID, Products.ProductName, Products.SupplierId, Products.
       CategoryId, Products.QuantityPerUnit, Products.UnitPrice, Products.UnitsInStock,
       Products.UnitsOnOrder, Products.ReorderLevel, Products.Discontinued
FROM Products
WHERE
 Products.ProductId < 36 AND
 Products.SupplierId > 50 AND
 Products.ProductName LIKE 'Chai%'

  Another feature of the QueryCriteria is field aliases. You can express this with :

qc.AddAlias(prod.GetField("Name"), "ProductName");
 
  The last feature i would like to write about is the join feature. Of course the
query criteria must allow joins. Let's suppose that the Product table has a 1:m
relation with the Suppliers. The query criteria can look like

Suppliers sp = new Suppliers();
QueryCriteria qcSupplier = new QueryCriteria(sp);

QueryCriteria qcProduct = new QueryCriteria(prod);
qcProduct.AddJoin(JoinType.Inner, prod.GetField("SupplierId"), sp.GetFiled("SupplierId"), qcSupplier);

  It's quite simple. We add the child criteria (qcSupplier) to the criteria of the main
tale (qc). The result is a join between the two tables.

  So there you have....the result is a nice, clean, object oriented way of writing queries.

 

 

 

 


 


 

posted Sunday, March 13, 2005 11:59 PM by Gheorghe Marius with 0 Comments

DataBlock

Here is it. You can download a PowerPoint presentation of my Data Access Framework and OR/M mapper for .NET from

www.voidsoft.ro/downloads/datablock.ppt

I will blog in the following days about the motives which lead me to create this.

 

 

posted Thursday, March 10, 2005 1:49 AM by Gheorghe Marius with 0 Comments

Gentle.NET
The version 1.0 of one of the most promising free OR/M tools was released. I am quite curios to see if, in time, Gentle will, in the .NET world, be as good as Hibernate (in the Java world). Download from http://www.mertner.com/projects/gentle/Gentle.NET.zip

posted Thursday, April 08, 2004 6:16 AM by Gheorghe Marius with 0 Comments

.NET books.
Hello everyone. My name is Gheorghe Marius and i'm a C# programmer from Romania. Enough of that...let's get down to business :-) I've finished reading Chris Sells "Programming Windows Forms in C#" last night and...well i was kind of dissapointed. It's not a bad book but frankly i was expecting more. More "hardcore content". Stuff that i can't find in the docs. A big chunk of the book was "fluff" that you can find in the SDK. Anyway if you're interested in WinForms and you are a newbie you should grab it. If you aren't a newbie....hold on to your money. Now....related to the .NET books. Is it just me or most of them just plain suck ? I mean....the "regular" .NET book seems to be just a rewrite of the SDK. Let's take the ADO.NET books...what informations do you find in, from the top of my head, "ADO.NET cookbook" that you can't find in the docs ??? The best .NET book....definetly Essential .NET by Don Box. Highly recommanded. What's your favourite .NET book ?

posted Monday, March 01, 2004 6:59 AM by Gheorghe Marius with 0 Comments




Powered by Dot Net Junkies, by Telligent Systems