Giter Club home page Giter Club logo

fluentcamlgen's Introduction

FluentCamlGen

CI Nuget Coverage Status

The fluent CAML Generator

This is a Generator for CAML, as used in SharePoint environments.

Installation

Using nuget use one of:

Install-Package FluentCamlGen
dotnet add package FluentCamlGen 
paket add FluentCamlGen

Status

Some features of CAML are supported. Some are not. Create an issue if you miss something.

Usage

Example 1

to create

<View>
  <Query />
  <ViewFields>
    <FieldRef Name="Title" />
    <FieldRef Name="Contact" />
    <FieldRef Name="UserName" />
    <FieldRef Name="UserEMail" />
    <FieldRef Name="UserMobilePhone" />
  </ViewFields>
  <ProjectedFields>
    <Field Type="Lookup" Name="UserName"  List="User Information List" ShowField="Name" />
    <Field Name="UserEMail" Type="Lookup" List="User Information List" ShowField="EMail" />
    <Field Name="UserMobilePhone" Type="Lookup" List="User Information List" ShowField="MobilePhone" />
  </ProjectedFields>
  <Joins>
    <Join Type="INNER" ListAlias="User Information List">
      <Eq>
        <FieldRef RefType="Id" Name="Contact"/>
        <FieldRef Name="ID" List="User Information List" />
      </Eq>
    </Join>
  </Joins>
</View>

one can write:

CG.View(
    CG.Query(),
    CG.ViewFields(
        CG.FieldRef("Title"),
        CG.FieldRef("Contact"),
        CG.FieldRef("UserName"),
        CG.FieldRef("UserEMail"),
        CG.FieldRef("UserMobilePhone")),
    CG.ProjectedFields(
        CG.ProjectedField("UserName", "Lookup", "User Information List", "Name"),
        CG.ProjectedField("UserEMail", "Lookup", "User Information List", "EMail"),
        CG.ProjectedField("UserMobilePhone", "Lookup", "User Information List", "MobilePhone")),
    CG.Joins(
        CG.InnerJoin("User Information List", "Contact")
        )
    ).ToString();

or alternatively:

CG.View()
    .Query()
    .ViewFields(vf =>
                vf.AddFieldRef("Title")
                    .AddFieldRef("Contact")
                    .AddFieldRef("UserName")
                    .AddFieldRef("UserEMail")
                    .AddFieldRef("UserMobilePhone"))
    .ProjectedFields(pf =>
                        pf.AddField("UserName", "Lookup", "User Information List", "Name")
                        .AddField("UserEMail", "Lookup", "User Information List", "EMail")
                        .AddField("UserMobilePhone", "Lookup", "User Information List", "MobilePhone"))
    .Joins(js => js.AddInnerJoin("User Information List", "Contact"))
    .ToString();

Example 2

to create

<View>
  <Query>
    <Where>
      <And>
        <Eq>
        <FieldRef Name="Year" />
        <Value Type="Number">2014</Value>
        </Eq>
        <Eq>
        <FieldRef Name="CalendarWeek" />
        <Value Type="Number">51</Value>
        </Eq>
      </And>
    </Where>
  </Query>
  <ViewFields>
    <FieldRef Name="Year" />
    <FieldRef Name="CalendarWeek" />
    <FieldRef Name="Workload" />
  </ViewFields>
  <QueryOptions>
    <ExpandUserField>False</ExpandUserField>
  </QueryOptions>
</View>

one can write:

CG.View(
    CG.Query(
        CG.Where(
            CG.And(
                CG.Eq(
                    CG.FieldRef("Year"),
                    CG.NumberValue(2014)),
                CG.Eq(
                    CG.FieldRef("CalendarWeek"),
                    CG.NumberValue(51))))),
    CG.ViewFields(
        CG.FieldRef("Year"),
        CG.FieldRef("CalendarWeek"),
        CG.FieldRef("Workload")),
    CG.QueryOptions(
        CG.ExpandUserField(false))).ToString();

or alternatively:

CG.View()
    .Query(q => q
        .Where(w => w
            .And(a => a
                .Eq(eq => eq
                    .AddFieldRef("Year")
                    .AddNumberValue(2014d))
                .Eq(eq => eq
                    .AddFieldRef("CalendarWeek")
                    .AddNumberValue(51)))))
    .ViewFields(vf => vf
        .AddFieldRef("Year")
        .AddFieldRef("CalendarWeek")
        .AddFieldRef("Workload"))
    .QueryOptions(qo => qo
        .ExpandUserField(false))
    .ToString();

Example 3

to create

<And>
    <Eq>
        <FieldRef Name='Year' />
        <Value Type='Number'>{0}</Value>
    </Eq>
    <And>
        <Geq>
            <FieldRef Name='CalendarWeek' />
            <Value Type='Number'>{1}</Value>
        </Geq>
        <Lt>
            <FieldRef Name='CalendarWeek' />
            <Value Type='Number'>{2}</Value>
        </Lt>
    </And>
</And>

one can write:

CG.And(
    CG.Eq(CG.FieldRef("Year"), CG.NumberValue(year)),
    CG.And(
        CG.Geq(CG.FieldRef("CalendarWeek"), CG.NumberValue(start)),
        CG.Lt(CG.FieldRef("CalendarWeek"), CG.NumberValue(end))
        )
    ).ToString();

or alternatively:

CG.And()
    .Eq(eq => eq.AddFieldRef("Year").AddNumberValue(year))
    .And(and => and
        .Geq(geq => geq.AddFieldRef("CalendarWeek").AddNumberValue(start))
        .Lt(lt => lt.AddFieldRef("CalendarWeek").AddNumberValue(end)))
    .ToString();

fluentcamlgen's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar nils-a avatar renovate-bot avatar renovate[bot] avatar

Watchers

 avatar  avatar

Forkers

nils-a ehtick

fluentcamlgen's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

cake
recipe.cake
  • Cake.Recipe 3.1.1
github-actions
.github/workflows/build.yml
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
  • actions/setup-dotnet v4.0.0@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
  • cake-build/cake-action v1@a6eb054329257c9e70a6c6bf01747ad6e1d9d52b
  • actions/upload-artifact v4@5d5d22a31266ced268874388b861e4b58bb5c2f3
  • actions/upload-artifact v4@5d5d22a31266ced268874388b861e4b58bb5c2f3
.github/workflows/codeql-analysis.yml
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-dotnet v4.0.0@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
  • github/codeql-action v3@1b1aada464948af03b950897e5eb522f92603cc2
  • cake-build/cake-action v1@a6eb054329257c9e70a6c6bf01747ad6e1d9d52b
  • github/codeql-action v3@1b1aada464948af03b950897e5eb522f92603cc2
  • ubuntu 22.04
.github/workflows/publishDocs.yml
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
  • cake-build/cake-action v1@a6eb054329257c9e70a6c6bf01747ad6e1d9d52b
.github/workflows/sonarcloud-analysis.yml
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
  • actions/cache v4@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
  • actions/setup-dotnet v4.0.0@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
  • actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
nuget
.config/dotnet-tools.json
  • cake.tool 1.3.0
src/CamlGen.Tests/CamlGen.Tests.csproj
  • xunit.runner.visualstudio 2.5.7
  • xunit 2.7.0
  • Shouldly 4.2.1
  • Microsoft.NET.Test.Sdk 17.9.0
  • Microsoft.CodeAnalysis.NetAnalyzers 8.0.0
  • AutoFixture.AutoMoq 4.18.1
src/CamlGen/CamlGen.csproj
  • StyleCop.Analyzers 1.1.118
  • Microsoft.CodeAnalysis.NetAnalyzers 8.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Please Add RowLimit

Can you please add the ability to add <RowLimit Paged="TRUE">70</RowLimit> as shown in the example below?

<View>
	<Query>
		<OrderBy>
			<FieldRef Name="FileLeafRef"/>
		</OrderBy>
	</Query>
	<ViewFields>
		<FieldRef Name="DocIcon"/>
		<FieldRef Name="LinkFilename"/>
		<FieldRef Name="Modified"/>
		<FieldRef Name="Editor"/>
		<FieldRef Name="FolderChildCount"/>
		<FieldRef Name="ItemChildCount"/>
	</ViewFields>
	<RowLimit Paged="TRUE">70</RowLimit>
	<JSLink>clienttemplates.js</JSLink>
	<XslLink Default="TRUE">main.xsl</XslLink>
	<ViewData/>
	<Toolbar Type="Standard"/>
	<Aggregations Value="Off"/>
</View>

Need Sharepoint Help

Hi @nils-a -
I need some help with Sharepoint's API and I figured you might be an expert. Can I hire you for a few hours?
If so, would you grab a time with me?
General Meeting

I'm trying to grab all fields of all objects in a collection.
I was using /_api/web/GetListUsingPath(DecodedUrl=@a1)/items but ran into the query string limit.

I think I need to switch to /_api/web/GetListUsingPath(DecodedUrl=@a1)/getitems but I dont understand the request structure.

Can you help?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.