Sayfalar

11 Mart 2012 Pazar

Creating Linq to Sharepoint Framework

This is my firs post of my blog. I explain how to coding entity framework like "Link to SQL" to sharepoint.
  1. Your generator have to tree const, those are root sitename,where the generate code (your project file path), and main namespace of code whice generated codes uses this own's left exc: mainnamespace.myentity1.myobjectset1
  2. You have to a regex or a function to getting truth field name from sharepoint field title exc: You don not define a field whice have space characters in c#.One of the sharepoint field is "Mail Adress",if you want to generate this object you must replace space characters.May be  "MailAdress"
  3. This generated object have to atrributes defined its internal name's or id's. This attributes provides us to access sharepoint objects.
  4. Yo have to a function to mapping your entity object to sharepoint object.This function get all of the mapping information from object attributes
  5. You may use poco code generator scrips or your own code generator class. I used my own.
  6. For generating entity class visit your root sharepoint site to access all site and visit each site's lists end each list's fields end write your generating script on this level
  7. Take care to special world of your ide. exc: c# do not support go,string,as,this ...etc. as e field name
  8. You have to user interface to generate your code from your sharepoint site when you want.This user interface maybe webpart,new project in your project,windows application ...etc.
  9. Linq to SQL use Expression<Func<T,bool>> parameters to generate SQL query.Like this you may use this parameter to generate caml query. Firstly you visit all expression and finding binary expression.Next step is convertion this binary expression to caml query.exc: entity1==a is a binary expression.Read entity1 attribute and get internal name,field type,list name and site name, write your caml query  "<FieldRef Name="entity1_internalname"/> <Value Type="Text>a</Value>" like this. And bind your entity object with returning object from sharepoint lists
  10. Finally your entity to sharepoint project is finished and you use entity to access sharepoint object and also you use linq to querying your sharepoint lists.  

Hiç yorum yok:

Yorum Gönder